Loop bug (solved) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Loop bug (solved)

Hey, I'm makin a Rock paper scissors game (random) and the while loops don't work properly. If you have the answer or another suggestion there're welcome. https://code.sololearn.com/c11a3A14A6a0 (I recomend to execute it at cmd)

25th Mar 2021, 4:56 PM
Mnl
Mnl - avatar
2 Answers
+ 1
you can use !game_over or not game_over Instead of comparing.. while game_over == False: and a = input() if a == "1" or a == "2" or a == "3": a = int(a) Instead of this simplify : a=input() if int(a) in rps: or just try to combine a=int(input()) and if a in rps: *** and you have use continue if input is wrong in else part.. else: print("type a number between 1-3") continue #add this I don't find what is the need of last inner while loop.... hope it helps..
25th Mar 2021, 9:20 PM
Jayakrishna 🇮🇳
+ 1
Thak you gor the tips Jayakrishna🇮🇳 , I solved the bug: at the end of the "win or lose" while loop, the play_again_bool changes to true (to stop the loop), but it doesn't change to false when the big while loop starts again, thats why it prints a lot of matches until a tie.
25th Mar 2021, 10:31 PM
Mnl
Mnl - avatar