alan.gauld at btinternet.com
Mon Dec 8 09:17:54 CET 2014
On 08/12/14 02:24, Steven D'Aprano wrote:
>> Python sees it like:
>> if FirstChoice == ('Coke' or 'Pepsi' or 'Water'):
>> So evaluates the bit in parens first which results in a boolean value of
> Actually it sees it as:
> if ((FirstChoice == 'Coke') or 'Pepsi' or 'Water'):
> which will always evaluate as True.
Oops, you're right.
> # The short way
> if FirstChoice in ('Coke', 'Pepsi', 'Water'):
Which is what I was suggesting so we get to the same end game :-)
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:
More information about the Tutor