Cheap VPS & Xen Server


Residential Proxy Network - Hourly & Monthly Packages

Python nested If


When we need to check for multiple conditions to be true then we use elif Statement.

This statement is like executing a if statement inside a else statement.

Syntax:

  1. If statement:
  2.     Body
  3. elif statement:
  4.     Body
  5. else:
  6.     Body

Example:

  1. a=10
  2. if a>=20:
  3.     print “Condition is True”
  4. else:
  5.     if a>=15:
  6.         print “Checking second value”
  7.     else:
  8.         print “All Conditions are false”

Output:

All Conditions are false. 

Comments

comments