+ 3

I need help...how can i print "you forgot to write a valid answer" only when the input is not rock scrissor or paper?

https://code.sololearn.com/cofKp77ihhMq/?ref=app

20th Oct 2018, 1:14 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
4 Antworten
+ 4
You can use an endless loop like this: my_choice = '' while my_choice not in ['rock', 'scissors', 'paper']: my_choice = input('Enter rock, scissors or paper: ') print('You chose', my_choice) This will keep asking the user for input until he enters either rock, paper or scissors: Enter rock, scissors or paper: jssj Enter rock, scissors or paper: potato Enter rock, scissors or paper: rok Enter rock, scissors or paper: rock You chose rock
20th Oct 2018, 4:11 PM
Anna
Anna - avatar
0
thx for help but I did it by my own: if my_choice not in ["rock", "scrissors" , "paper"]: print("You have to use only rock , paper or scrissors")
20th Oct 2018, 5:49 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
0
Add an else if (elif)
2nd Nov 2018, 12:00 AM
Apersonthatsbored