Every time I enter 4, 6 or 12 it doesn't accept it. Why? The code looks fine to me. Please tell me how to correct or what to change.
import random
def roll_the_dice():
print("Roll The Dice")
print()
repeat = True
while repeat:
number_of_sides = input("Please select a dice with 4, 6 or 12 sides: ")
if (number_of_sides in [4,6,12] and len(number_of_sides) == 0 and
number_of_sides == int):
user_score = random.randint(1,number_of_sides)
print("{0} sided dice thrown, score {1}".format(
number_of_sides,user_score))
roll_again = input("Do you want to roll the dice again? ")
roll_again.lower()
if roll_again == "no":
print("Have a nice day")
repeat = False
elif len(roll_again) == 0:
print("Error please type 'yes' or 'no'")
roll_again = input("Do you want to roll the dice again? ")
else:
print("You have entered an incorrect value, please try again")
number_of_sides = input("Please select a dice with 4, 6 or 12 sides: ")
number_of_sidescannot simultaneously be one of 4, 6, or 12 and be a string of length 0. In no case can you enter a string that is equal to the typeint.