continue statement | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

continue statement

can anyone explain to me why should put TRUE ? because when i try write the code by myself it isn't run correctly i = 0 while True: i = i +1 if i == 2: print("Skipping 2") continue if i == 5: print("Breaking") break print(i) print("Finished")

22nd Jan 2019, 12:52 PM
Abdulrahman Awad
Abdulrahman Awad - avatar
3 Answers
+ 3
It seems correct. Can you show what error do you get? The expected output is: 1 Skipping 2 3 4 Breaking Finished
22nd Jan 2019, 1:02 PM
Pedro Tortello
Pedro Tortello - avatar
+ 2
In addition to what Abdul rahman said, True is used with while to make an infinite while loop. Since there is a breaking condition so it won't be infinite in this case.
22nd Jan 2019, 1:28 PM
Шащи Ранжан
Шащи Ранжан - avatar
+ 1
thank you guys so much I got it
22nd Jan 2019, 5:32 PM
Abdulrahman Awad
Abdulrahman Awad - avatar