From cbe1c60774d5d7e3fa67147899d9e7f867944e91 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Sun, 26 Feb 2017 20:29:50 +0100 Subject: [PATCH] Abort on empty text, replace recursion with while loop --- lyricsmanager.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lyricsmanager.py b/lyricsmanager.py index 3b0d464..01944a9 100755 --- a/lyricsmanager.py +++ b/lyricsmanager.py @@ -18,7 +18,10 @@ def queryLyrics(ref = 0): else: out = text - if len(out) > 130: + if len(out) == 0: + print("No input. Aborting.") + return False + elif len(out) > 130: print("Text too long (%i characters)" % len(out)) return queryLyrics(ref) @@ -32,7 +35,9 @@ def queryLyrics(ref = 0): ans = input("Add follow-up lyrics? [Y/n] ") if ans.lower() != "n": - queryLyrics(row) + return True + return False if __name__ == "__main__": - queryLyrics() + while queryLyrics(): + continue