May-06-2017, 07:48 PM
(May-06-2017, 07:43 PM)ichabod801 Wrote: You need elif, which is an abbreviation for 'else if'. It gives another condition to check if the previous conditions haven't been met.
menu() selection = input('What is your command? ').lower() if command == 's': print('Spam spam spam spam') elif command == 'c': print(1, 2, 5) elif command == 'i': print('Nobody expects the Spanish Inquisition!') else: print('Unknown command')Typically, this sort of command checking is done in awhile True:
loop, with a break if the command is q, or quit, or exit, or something like that.
So for examples sake would I place that in here and then do it for each command?
selection=input("Please Select:") l = file = open("C:\\Users\\LiquidO\\Desktop\\Assingment 2 python\\movies.txt", "r") if selection =='l': movies_list = file.readlines() movies_list = [movie.strip() for movie in movies_list] print("Movies now loaded") elif selection == 'r': print("Random choice selected") r = print(random.choice(movies_list)) else: print ("Unknown Command")