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

2018-10-06 Thread eliteanarchyracer
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 all dice in the list are either a 1 or 5 , I want to calculate a result.
if there is a 2,3,4 or 6 in the list i want to let the user roll again
FOR EXACT LINE: PLEASE CHECK CODE


CODE: 


from random import *

class Dice:

def __init__(self, sides, color="white"):
self.sides = sides
self.color = color

def roll_dice(self):
result = randint(1, self.sides)
return result


die1 = Dice(6)
die2 = Dice(6)
die3 = Dice(6)
die4 = Dice(6)
die5 = Dice(6)

alldice = [die1, die2, die3, die4, die5]

result = []

start = input("Press enter to roll your dice:")

for object in alldice:
temp = object.roll_dice()
result.append(temp)
print(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")
-- 
https://mail.python.org/mailman/listinfo/python-list


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

2018-10-06 Thread eliteanarchyracer
Well these worked like a charm. Cant say I understand some of them and will 
have to look into utilizing them in the future, but I appreciate everyones 
responses and thank you all. Never needed to check for multiple instances in a 
list before.

Nice to have help!
-- 
https://mail.python.org/mailman/listinfo/python-list