--Originally published at Programming Fundaments
A nested construct is one where you have a “if, elif, else” statement inside an “if, elif, else”. It just a combination of the last couple of blogs, but a little more complex. Example
#!/usr/bin/python var = 100 if var < 200: print "Expression value is less than 200" if var == 150: print "Which is 150" elif var == 100: print "Which is 100" elif var == 50: print "Which is 50" elif var < 50: print "Expression value is less than 50" else: print "Could not find true expression" print "Good bye!"
And it should result in something like this:
Expression value is less than 200 Which is 100 Good bye!
Not so complex really….
Examples and more from: https://www.tutorialspoint.com/python/nested_if_statements_in_python.htm