[Tutor] if syntax expression help

Peter Otten __peter__ at web.de
Thu Nov 25 22:47:19 CET 2010


Rance Hall wrote:

> I have a user entered variable that I need to check to see if they
> entered one of the two legal values.
> 
> But I only need to check this if one other fact is true.
> 
> 
> we have a variable called "mode"  whose value is either "add" or
> "edit" based on how we where called.
> 
> we have a userentry variable tied to an imput function.
> 
> My current if statement looks like this:
> 
>             if ((userentry.lower != "c" or userentry.lower != "i") and
> mode == "add"):

Hint:

>>> userentry = "YADDA"
>>> userentry.lower
<built-in method lower of str object at 0x7f94961f5ba0>
>>> userentry.lower()
'yadda'




More information about the Tutor mailing list