Jul-17-2020, 06:56 PM
(This post was last modified: Jul-17-2020, 06:59 PM by BitPythoner.)
You actually don't need 3 questions, you can string them into one:
Also, on line 21, why do you put except Exception? That is not necessary, except by itself catches all exceptions.
def calculator1(): global num1, num2, op equation = input("Enter an equation: ") try: answer = eval(equation) #This is the cool part, eval can actually take string input and do arithmetic operations with it. print("Your answer is: ", answer) except: print("ERROR: INVALID") calculator1()
Also, on line 21, why do you put except Exception? That is not necessary, except by itself catches all exceptions.