I'm programming a dice game, that uses the random function. When you run the program it rolls two dice once and asks the user if they want to roll the dice again. My main problem is that after the initial dice roll has been processed and the program asks the user if they want to roll again it causes an infinite loop that I don't know how to stop. How do I prevent an infinite loop in a while statement when the program is testing a string input? Thanks in advance.
import random
print ('Welcome to the DICE GAME!')
die1 = random.randint(1,6)
die_1 = random.randint(1,6)
print(die1, die_1)
print("Your initial score is: " + str(die1 + die_1))
yes_or_no = input(' Would you like to restart the dice game. Print "Y" or "y" to continue. Type anything else to exit. :')
print (yes_or_no)
while yes_or_no == 'y' or "Y":
print(die1, die_1)
else:
print('Thanks for playing the DICE GAME! Goodbye.')