+ 1
Python Break statement
How to take back a break statement back i to the loop, each time i try print, it says something like: File "source_file.py", line 1 break ^ SyntaxError: 'break' is outside of loop
3 Réponses
+ 3
Instead of using break try continue, this acts like break but moves on to the next loop while break exits the block, also spacing counts so break should be at the same indentation.
If you post the code throwing the exception I could help more
+ 3
The error message says that you're using a break statement in line 1. That's impossible since a break statement must be in a loop:
while True: # start loop
print() # do something
break # break loop
+ 1
Use continue if you want to go back to the loop and break if you wanna finish the loop