So I have written this code and I want to make the function check to see if the random.choice matches the input from the user however, I have used if x in numbers: which checks to see if x matches one of the numbers from the list. That's not what I want and so my question is, how can I make this possible. I know my code is really hard to see but right now that is not my concern
import time
import random
tokens = 10
age = int(input("Enter your age: "))
legal = 18
numbers = [1,2,3,4,5,6]
x = int()
answer = str()
def aboveage():
if (int(age)) >= (int(legal)):
print("You are old enough to play")
time.sleep(0.5)
else:
print("You can't play")
if (int(age)) >= (int(legal)) and (int(tokens)) >= 10:
answer = input("Would you like to bet?: ")
if answer == "yes":
x = int(input("Choose the number the die will show: "))
if x in numbers:
print("The die is rolling...")
time.sleep(2)
print(random.choice(numbers))
if x in [1,2,3,4,5,6]:
print("You won!")
else:
print("You lost :(")
else:
print("You need to guess a number between 1-6")
else:
print("Try again later")
elif (int(age)) < (int(legal)):
print("You are underage")
else:
print("You don't have enough tokens")
if x in numbers:
print("Congratulations you won! :)")
else:
print("You lost :(")
return
aboveage()
Aucun commentaire:
Enregistrer un commentaire