I heard eval
was very bad practice in Python because of security issues.
So I was wondering if there is a way I could not use eval
in this program.
for _ in range(10):
n1 = random.randint(1, 10)
n2 = random.randint(1, 10)
operator = random.choice("+-*")
question = (n1,operator,n2)
questionNo +=1
useranswer = input(question+" = ")
answer = eval(question)
if useranswer == str(answer):
correct += 1
print('Correct!Your score is, ", correct)
else:
print('Wrong Your score is, ", correct)