0

Hi, hope you're doing good.Could someone please tell me why does the while loop not stop when I type in rock, paper or scissors?

Here's the code: while True: choices = ["rock", "paper", "scissors"] user_choice = input("What is your choice, rock,paper or scissors: ") if not user_choice == choices[0] or choices[1] or choices[2]: print("Please enter rock, paper or scissors! ")

1st Dec 2022, 12:10 AM
JTonMobile
6 Answers
+ 4
This should be the code: while True: choices = ["rock", "paper", "scissors"] user_choice = input("What is your choice, rock,paper or scissors: ") if user_choice not in choices: print("Please enter rock, paper or scissors! ")
1st Dec 2022, 1:45 AM
Yusuf C
+ 1
Ohh yesss thank you so much
1st Dec 2022, 1:51 AM
JTonMobile
+ 1
Yes Lochard thank you for adding that but I already knew it I just wanted to know about the specific part I asked for as Yusuf said. Thanks to you guys y'all are awesome
1st Dec 2022, 11:16 AM
JTonMobile
0
The loop still doesn't break. Maybe you want somethin like this? https://code.sololearn.com/cvqS2ZFQ0i9n/?ref=app
1st Dec 2022, 6:01 AM
Lochard
Lochard - avatar
0
Lochard he never asked for it to break, he asked for the loop to work. it was best if he figured the rest out himself
1st Dec 2022, 7:44 AM
Yusuf C
0
He asked why the while loop does not stop when he types in one of the choices in the title. So I guess that's what he wants. You are right about letting him figure out though. I guess I just wanted to practice coding.
1st Dec 2022, 7:50 AM
Lochard
Lochard - avatar