Python Break Function Doesn't End While True
Why will the break not end the while true and return to the start? while True: print('This is a quiz') print('What is your name?') Name = input() print('Hello ' +
Solution 1:
break
exists the entire while
loop.
continue
is what you're looking for, returning to the next while
iteration.
You can read more about control flow tools, break
and continue
in the official docs: http://docs.python.org/2/tutorial/controlflow.html#break-and-continue-statements-and-else-clauses-on-loops
(You also have some other bugs as others have mentioned correctly)
Solution 2:
use the "continue" keyword, not "break".
Solution 3:
....
answer1 = ["True", "true"]
...
if not(qanswer in answer1):
print('Sorry, the answer is: ' + answer1)
breakelse:
print("Correct! Here's the next question")
Post a Comment for "Python Break Function Doesn't End While True"