Hi I have been trying to write a dice rolling program and I just got this error can you tell me whats wrong with my code and offer me a solution to fix it? Thanks.
import random
while True:
dice_type = int(input("would you like to roll a 4,6 or 12 sided dice"))
if dice_type in[4,6 or 12]:
break
print("Sorry that is not the correct input")
score = random.randint(1, dice_type)
print ("The dice you threw was a %d-sided dice" %dice_type)
print ("You rolled a %d" %score)
update:
Ok I have tweaked the program so that it looks like this...
import random
while True:
dice_type = int(input("would you like to roll a 4,6 or 12 sided dice:"))
score = random.randint(1, dice_type)
print ("The dice you threw was a %d-sided dice" %dice_type)
print ("You rolled a %d" %score)
It now works. thanks for the quick responses everyone. if you have found a way to make the program reject incorrect values being entered please comment a solution.