i do't understand the break statment in contniue code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

i do't understand the break statment in contniue code

25th Dec 2019, 12:18 PM
Akanksha arya saini
Akanksha arya saini - avatar
6 Answers
+ 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).
25th Dec 2019, 1:07 PM
Ipang
+ 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
25th Dec 2019, 12:36 PM
Nico Ruder
Nico Ruder - avatar
+ 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
25th Dec 2019, 12:52 PM
Pattern
Pattern - avatar
+ 1
ok i think i should revise C :)
25th Dec 2019, 2:35 PM
Akanksha arya saini
Akanksha arya saini - avatar
0
ok ...thanks
25th Dec 2019, 12:46 PM
Akanksha arya saini
Akanksha arya saini - avatar
0
ok then after break what does print (i) do prints ?
25th Dec 2019, 12:54 PM
Akanksha arya saini
Akanksha arya saini - avatar