Unconditional Statements:
So far we have discussed break, continue statements. Today we will learn about pass statement.
pass statement:
#Example program on pass
statement
#Dislay odd nos's without
using not equal to operator
a=[4,7,9,10,11] #one list is
created
for n in a:
if n%2==0:
pass
else:
print(n)
"""output:
7
9
11
>>>
"""
The pass statement does not do
anything. It is used with ‘if’ statement or inside a loop to represent no
operation. We use pass statement when we need a statement syntactically but we don’t
want to do any operation.
Next Topic: The else suite
Previous Topic:
No comments:
Post a Comment