[Tutor] How to handle conjunction operators
Alan Gauld
alan.gauld at btinternet.com
Mon Nov 28 01:35:45 CET 2011
On 27/11/11 19:02, Hugo Arts wrote:
> if name[0] == "m" or name[0] == "f" or name[0] == "b":
>
> or, more idiomatically, you can use the in operator like this:
>
> if name[0] in ("m", "f", "b"):
And you might want to force it to lower case too:
if name[0].lower() in ("m", "f", "b"):
OTOH you might want it to be case sensitive...
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list