The below example show how to use if else in python.A variable a is initialized to 1. Then in the if - else conditon the variable is searched and if matched then that branch is taken. in this example the else if condition is matching.
#!/usr/bin/python
a = 1
if a == 10 :
print "The variable is not matching"
elif a == 1:
print "The variable ", a ," is matching"
else:
print "No condition matched"
Comments
Post a Comment