Search code examples
pythonprompt

Python yes/no def


I'm using the example below:

APT command line interface-like yes/no input?

I want to make it its own definition as outlined then call it upon demand, like this:

def log_manager():  
    question = "Do you wish to continue?"  
    choice = query_yes_no_quit(question, default="yes")  
        if choice == 'y':  
            print ("you entered y")  
        else:     
            print ("not working")  

Regardless of what I input, "not working" is always printed. Any guidance would be really appreciated!


Solution

  • The function returns True/False. So use if choice:

    Btw, you could have easily found out the solution on your own by adding print choice ;)