- 1
How can i use while break and continue
How can i use while break and continue
2 Antworten
+ 1
Do courses in these order : python beginner , next intermediate , next data structures. Revise all learnings in python core.
All topics explained with examples there. Mention specific which you don't understand in those specific topics.
An ex:
I=0
while I<10 :
if i%2==0:
continue
if I==5 :
break
print(I)
I+=1
1st if skips current iteration if I is even , 2nd if breaks loop if I==5 is true
in other cases prints I and output you get
1
3
only.., Without break, while loop runs from I=0 to I<10 becomes false.
0
Break means totally exit the loop
And continue means skip a specific iteration