From d0178defa617d97615a7128b6a1ff12a177e5cfc Mon Sep 17 00:00:00 2001 From: Ritiek Malhotra Date: Sat, 18 Feb 2017 13:39:44 +0530 Subject: [PATCH] optimize code --- spotdl.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/spotdl.py b/spotdl.py index 94b0c0f..8310cd0 100644 --- a/spotdl.py +++ b/spotdl.py @@ -43,13 +43,12 @@ def searchYT(number): print((str(check) + '. ' + x.get_text()).encode('utf-8')) links.append(x.find('a')['href']) check += 1 - is_error = True print('') - while is_error: + while True: try: the_chosen_one = int(raw_input('>> Choose your number: ')) if the_chosen_one >= 1 and the_chosen_one <= len(links): - is_error = False + break else: print('Choose a valid number!') except KeyboardInterrupt: