0
i do't understand the break statment in contniue code
6 Respuestas
+ 3
* `break` statement forces the execution flow to leave the loop block, even when <condition> still satisfies.
while <condition>:
# code
break --------------
|
# code <-------------
* `continue` statement forces to ignore the instructions following the `continue` statement and start over from the first instruction within the loop body.
while <condition>:
# code <----------
# code |
continue ---------
The functionality and use case of `break` and `continue` statement is similar regardless of the loop type (for-loop or while-loop).
+ 1
If you past continue it jumps over all following in the loop and continues after it. Break like it says breaks the loop and continues after the loop
+ 1
"""break statement stops the code from running when it reaches a certain point"""
#ex
i = 0
while True:
i = i +1
if i == 2:
continue # here continue tells the code that it should skip 2
if i == 5:
break # and here break stops the code from runing when it reaches 5
print(i)
#we can use break just in while loops
+ 1
ok i think i should revise C :)
0
ok ...thanks
0
ok then after break what does print (i) do prints ?