Created a little program that generates two values between 1 and 10 (inclusive), and prompts the user to find the sum as an answer.
I'm trying to use a while loop here. It seems that the code "while (numb1 + numb2 != answer)" will always evaluate to true (even when false), and so the loop never exits.
Wondering what I might have missed? Would appreciate any input!
import random
numb1 = random.randint(1,10)
numb2 = random.randint(1,10)
print('What is: ', numb1, ' + ', numb2, '?')
answer = input('Answer: ')
while (numb1 + numb2 != answer):
print('Incorrect, try again!')
answer = input('Answer: ')
print('Correct!')
inputreturns a string, butnumb1andnumb2are integers. Cast to an int before comparing:answer = int(input('Answer: '))