Answer to Question #256494 in Python for rasi

Question #256494

 26. difference between Break and Continue statements with an example python program?

 


1
Expert's answer
2021-11-01T18:47:37-0400
# The continue statement starts the next pass of the loop
# bypassing the rest of the loop.
print("loop with continue statement: ")
for i in (1,2,3,4,5):
    if i == 3:
        #if i=3 then go to the next iteration
        continue
    print(i)
#The break statement terminates the loop early.
print("loop with break statement: ")
for i in (1,2,3,4,5):
    if i == 3:
        #if i = 3 then stop the loop
        break
    print(i)

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS