Python break, continue and pass Statements

break Statement:

  1. used to stop the looping statement before the given condition becomes False.
  2. Used only in the looping statements like while or for.

Example for break:
# break example in python
for i in range(1,10):
if i==6:
break
else:
print(i)
Note: Loop Stops when the i value is 6.

continue Statement:

  1. Used to skip the current iteration
  2. Used only in the looping statements like while or for.

# continue example in python
for i in range(1,11):
if i==6:
continue
else:
print(i)

pass Statement

  1. to Stop and proceed while executing the program

# pass example in python
for i in range(1,10):
if i==6:
pass
print(“pass command”)
print(i)

Win Corporate Training
website: http://www.wincorptrg.com
View My Profile

Advertisements