I made a function for a program I am making, It's a math game where you have to input an answer, and if the answer is right you win. I thought the game was simple, but for some reason, whenever you input the answer, the program says it's wrong, even if the answer is right.
def gameChoice():
print("what game do you want to play? A math game")
game_choice = input(">>")
if game_choice == 'math game':
number1 = random.randint(1, 30)
number2 = random.randint(1, 30)
answer = (number1 + number2)
print("%d + %d = %d" %(number1, number2, answer))
player_answer = input(">> ")
if player_answer == answer:
print("congrats, you got it right")
else:
print("sorry, try again")