What I want to do is to input a formula, like 1+1, and print: The Answer of question n is : (The answer of the formula). For 1+1, it should print: The Answer of Question 1 is: 2 But what I get is, when I input 1+1, it prints: The Answer of Question 1 is: '1+1'
def prefix():
typein=int(input("How many questions do you want to ask:"))
number=1
while number<typein+1:
a=input("Question %r you want to ask"%(number))
print(a)
print("The Answer of Question %r is: %r" %(number,a))
number+=1
prefix()
When I add
print(a)
after
a=input("Question %r you want to ask"%(number))
It shows that a is 1+1, not 2. So how can I let a become the answer of the formula but not the formula itself?
--------------------------Edit-----------------------
It asks people to input an int ,and some formulas. There is no problem for us to input an int for the first part of the code. But for the second part of the code, which asks as to input the formula, it comes wrong.