+ 1

How to use continue and break statement in phython???

prob...

20th Jul 2018, 8:36 PM
Praneet Negi
Praneet Negi - avatar
2 Answers
+ 3
The "break" keyword is used to break out of a loop(any type of loop). The "continue" is used to skip an iteration. Take a look at an example =============== for i in range(5): if i > 3: break print(i) Output ====== 0 1 2 3 when it gets to 4, it "breaks" out of the loop Example of "continue" ================== for i in range(10): if i == 6: continue print(i) Output ======= 0 1 2 3 4 5 7 8 9 As you can see, 6 is not printed, because when it got to 6, it "continued" without printing 6
20th Jul 2018, 9:11 PM
Dlite
Dlite - avatar
+ 1
thank you
21st Jul 2018, 9:57 AM
Praneet Negi
Praneet Negi - avatar