1

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!

Community
  • 1
  • 1
Publiccert
  • 193
  • 4
  • 17
  • What is the return value, `choice`, from the `query_yes_no_quit()` function? Please print that and **update** your question. – S.Lott Feb 02 '11 at 23:42

2 Answers2

9

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 ;)

ThiefMaster
  • 298,938
  • 77
  • 579
  • 623
1

Use:

if choice:
    print("you entered y")
else:
    print("not working")

the function returns True / False, not "y" / "n".

meshy
  • 7,806
  • 8
  • 48
  • 69
max
  • 45,169
  • 49
  • 189
  • 342