In my code I'm making a basic multiplying game.
But in my game,
When you get the answer right, it says you got it wrong
Here's my whole code:
import random
score = 0
while True:
num1 = random.choice(range(1,12))
num2 = random.choice(range(1,12))
answer = num1 * num2
a = input("Solve for " + str(num1) + "x" + str(num2))
if a == answer:
print("congrats you got it right")
score += 1
else:
print("Wrong sorry play again")
print("Score was: " + str(score))
break
When I get the right answer I get
Solve for 7x10 70
Wrong sorry play again
Score was: 0
Other languages might let you get away with this, but Python is strongly typed. The input function gets a string, not a number. Numbers can't be equal to strings. Either convert the number to a string or the string to a number before you compare them. You can use
str
orint
to convert.