Issue
I have a code sample where the problem is:
while True:
for i in range(3):
i = input()
if i == 'quit'
break
else:
print('Try again')
When I type quit in my input it doesn't break out of the code. Thanks for your help!
Solution
Try using this code:
while True:
i = input()
if i == 'quit'
break
print('Try again')
I removed for loop because it has no usage and for loop is the reason of break not working because you are breaking out of for loop and not the while loop. I also removed else in if statement.
Answered By - BokiX
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.