It’s my second program in Python. I seem to be happy with my progress. The question is I am trying to make is:
choice=eg.ynbox(msg='wat to do')
for["true","1"] in choice:
print("yes")
for["false","0"] in choice:
print("no")
The problem is that this for condition is not working. I have seen such code while I was looking up answers for my previous question but I forget. I tried googling but I dont know how to put this in words..A little syntax help is necessary
BTW: its a gui program with easygui 0.96..
I assume by
eg.ynbox(msg='wat to do')you mean you are creating a Yes/No dialog box. This means that the value stored inchoiceis anIntegerwhere 1 represents True and 0 represents False. This is correct in both Python 2.x and Python 3.x as long as True and False have not been reassigned in Python 2.xTrueandFalseare reserved keywords in Python 3.x and thus are guaranteed not to change. Therefore, you simply have anifstatement that works using this value:You do not need to match on
1and0since they represent bothTrueandFalse.