mardi 22 septembre 2015

nesting if statement inside each other in python [on hold]

I'm not sure if I understood this from the instructor well, and the example below shows what he illustrated..

monday = True
freshCoffee = False
if monday :
    #you could have code here to check for fresh coffee

    #the id statement is nested, so this if statement
    #is only executed if the other if statement is true
    if not freshCoffee :
        print('go buy a coffee!')
    print("I hate Mondays")
print("Now you can start work")

Aucun commentaire:

Enregistrer un commentaire