osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Creating dice game : NEED HELP ON CHECKING ELEMENTS IN A LIST


On 2018-10-06, eliteanarchyracer at gmail.com
<eliteanarchyracer at gmail.com> wrote:
> Hi, I am new to python and would like someones help on the
> following:
>
> After rolling 5 dice and putting the results into a list, I
> need to check if any dice is not a 1 or 5.

if any(roll != 1 and roll != 5 for roll in result):

> # ----- THIS LINE IS WHERE I NEED HELP ---- # ( if 2, 3, 4, 6 in list: )
>     print("you can roll again")
> else:
>     print("you have all 1's and 5's in your result")

Ha! Didn't think I'd get to apply DeMorgan's Law so soon.

-- 
Neil Cerutti