Fix getting input in python3

This commit is contained in:
Ritiek
2017-06-22 02:27:18 +05:30
parent 1b1d24c8a2
commit 258b21ff05
2 changed files with 8 additions and 6 deletions

View File

@@ -13,7 +13,7 @@ except:
def input_link(links):
while True:
try:
the_chosen_one = int(raw_input('>> Choose your number: '))
the_chosen_one = int(user_input('>> Choose your number: '))
if the_chosen_one >= 1 and the_chosen_one <= len(links):
return links[the_chosen_one - 1]
elif the_chosen_one == 0:
@@ -23,6 +23,12 @@ def input_link(links):
except ValueError:
print('Choose a valid number!')
def user_input(string=''):
if sys.version_info > (3, 0):
return input(string)
else:
return raw_input(string)
# remove first song from .txt
def trim_song(file):
with open(file, 'r') as fin: