[Tutor] Risk Dice Program

Mark Lawrence breamoreboy at yahoo.co.uk
Wed Jan 28 07:12:57 CET 2015


On 28/01/2015 01:28, Alan Gauld wrote:
> 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...
>

Forget it, just me being a burke, I must remember not to post after 
midnight :)

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Tutor mailing list