Snippets Collections
 1. var = 100 # var is a variable.
2.if var < 200:
   3.print "Expression value is less than 200"
   4.if var == 150:
      5.print "Which is 150"
   6.elif var == 100:
      7.print "Which is 100"
   8.elif var == 50:
      9.print "Which is 50"
   10.elif var < 50:
      11.print "Expression value is less than 50"
12.else:
   13.print "Could not find true expression"
 
14.print "Good bye!"
 
When the above code is executed, it produces following result −
Expression value is less than 200
Which is 100
Good bye!
bookmark
dashboard

Mon Mar 30 2020 12:23:56 GMT+0000 (UTC) https://www.tutorialspoint.com/python/nested_if_statements_in_python.htm

#python #python #ifstatement #nestedif statement

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension