[Tutor] Problem with if statements and else statements
Alan Gauld
alan.gauld at yahoo.co.uk
Sun May 28 20:17:34 EDT 2017
On 29/05/17 00:12, Alex Kleider wrote:
> On 2017-05-28 13:13, Mats Wichmann wrote:
>
>> FWIW, if checking for multiples, you could also write:
>>
>> if Month in ['January', '1']:
>
> Would
>
>>>> if Month in {'January', '1'}:
>
> be even better? (regarding efficiency perhaps? Trivial point, I know,
> but just wondering.)
If in doubt try it out and profile/time it.
But I don't think it will make much difference since ultimately
it still has to test each value (although a hashing algorithm
may be involved that works on partial matches...) But if in
doubt...
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list