Tuesday, 9 July 2019

pass statement

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.

It is just like null statement in Java.

Next Topic: The else suite
Previous Topic: 

No comments:

Post a Comment

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(...