[Tutor] Risk Dice Program

Alan Gauld alan.gauld at btinternet.com
Wed Jan 28 02:28:52 CET 2015


On 28/01/15 00:09, Mark Lawrence wrote:

>> To get round that you need to explicitly compare o_die1
>> to both values:
>>
>>       if (o_die1 > d_die1) or (o_die1 > d_die2):
>>
>
> I consider the chained comparisons shown here
> https://docs.python.org/3/reference/expressions.html#not-in to be far
> more Pythonic.  It also avoids the superfluous brackets which always
> drive me around the bend.

Sorry Mark, I'm missing something. How would chained comparisons work
for this case? Especially a not-in?
You can avoid the compound test using any() and a generator as per my 
earlier post but I can't think how a chained test would work here?

But it is getting late...

-- 
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