0

Inputs + Multiple Choice?

So I have a task at school, and haven't been able to find out how to do this so I came here. Is it possible to have an input and have the user be able to write in more than 1 expected string? So I have this so far; input ("Please enter a command.") help = input ("Showing available commands: [havent written in all the commands here yet]) But if I were to do something such as put walk forwards = input ("You walk forwards") after the help = input ...I'd get an error. Any ideas how it can be multiple choice?

10th Nov 2016, 7:32 AM
Nitroxium
Nitroxium - avatar
2 Réponses
+ 1
I would use multi line comment to display menu on your console, choice=None while choice !="0": print ( '''Main Menu 0-exit 1-something 2-something etc....''') choice=input ("Choose on of the above") if choice =="0": print ("Bye") break elif choice=="1": do something ...... ....... else: print (choice, " doesn't exist)
10th Nov 2016, 11:20 AM
Mateusz Wiezik
Mateusz Wiezik - avatar
0
I'm not exactly sure what you're trying to do, but if you know the choices in advance you could give the user a numbered list to choose from and then only ask for the respective number with input(), e.g. print "Available commands:" print "(1) walk forwards" print "(2) exit" choice = input("please enter number") hope that helps.
10th Nov 2016, 9:27 AM
Alex
Alex - avatar