How do I exit a while loop upon user input? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How do I exit a while loop upon user input?

I have a dice rolling game and everything is working properly except for the fact that i cant exit the while loop with the user input i wrote in the program

26th Mar 2019, 11:50 PM
Jesse Douglas
Jesse Douglas - avatar
2 Answers
+ 2
You can use the break statement for that. Add this to then end of your code. if user_input == "exit": break
27th Mar 2019, 12:50 AM
Diego
Diego - avatar
- 1
https://code.sololearn.com/cZ8yrUM7b19a/?ref=app somehow it becomes an infinite loop
27th Mar 2019, 1:14 AM
Jesse Douglas
Jesse Douglas - avatar