what is the difference between these codes? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what is the difference between these codes?

i = 0 while True: i = i + 1 if i == 3 print(“Skipping 3”) continue if i == 5: print(“Breaking”) break print(i) print(“Finished”) and i = 0 while True: print(i) i = i + 1 if i == 3 print(“Skipping 3”) continue if i == 5: print(“Breaking”) break print(“Finished”) why do I have both of Skipping3 and 3 outputs if ‘print(i)’ is in front of if statements? :))

2nd Apr 2019, 3:30 AM
hyeran lee
hyeran lee - avatar
1 Answer
+ 5
'continue' sends execution control to the first line of the loop, which is where print(i) would be if you place it in front of the if statements.
2nd Apr 2019, 3:42 AM
Hatsy Rei
Hatsy Rei - avatar