I made a simple Yahtzee game in as few of lines as I could think. Currently, the user must press Enter (with any value) to continue. I would like to use a loop statement so that the dice continue to roll until Yahtzee (all rolled numbers are the same). I would also like a 10 second timer. What is the best way to add a loop statement to this code? P.S. This is not homework, I wanted to make this game for my Yahtzee nights. My daughter wakes easil...haha
import random
while True:
dice1 = random.randint(1,6)
dice2 = random.randint(1,6)
dice3 = random.randint(1,6)
dice4 = random.randint(1,6)
dice5 = random.randint(1,6)
numbers = (dice1, dice2, dice3, dice4, dice5)
sum1 = sum(numbers)
if sum1 == ("5" or "10" or "15" or "20" or "25"):
print("Winner, winner, chicken dinner!", dice1, dice2, dice3, dice4, dice5)
else:
print("Your rolls are: ", dice1, dice2, dice3, dice4, dice5)
input("Press return key to roll again.")
EDIT: This is my final product. Thank you for all the help guys!!
import random
import time
input("Press return key to roll.")
for x in range(0,10000):
numbers = [random.randint(1,6) for _ in range(5)]
if all(x == numbers[0] for x in numbers):
print("Winner, winner, chicken dinner!", numbers)
input("Press return key to play again.")
else:
print("Your rolls are: ", numbers)
print("Next roll in one second.")
time.sleep(1)