vendredi 5 novembre 2021

if/else/while not executing conditions python

I'm a beginner in Python and I'm struggling to find my mistake. I have 3, now two conditions for input, and not sure what the problem is. I have tried implementing in various ways, from using all if statements then if/else, then nesting as well as while loop. I'm not sure what I'm doing wrong.

def switch_off():
    robot_name
    answer = input (robot_name + ": what must I do next? " )
    
    if answer == "OFF":    
         quit()   
    if answer.lower() != "off":
        print( robot_name + ": Shutting down...")
    if answer== "OFF" or answer.lower() != "off":
        print(robot_name + ": Sorry, I did not understand")
        answer = input (robot_name + ": what must I do next? " )

Aucun commentaire:

Enregistrer un commentaire