Simple Calculator exercise
Hey all i keep getting this error whenever i try to run the code even tho at some point i just copied and pasted the code into my code editor. > while True: print("Options") print("Enter 'add' to add two numbers") print("Enter 'substract' to substract two numbers") print("Enter 'multiply' to multiply two numbers") print("Enter 'divide' to divide two numbers") print("Enter 'quit' to end the program") user_input = input("Enter your operation:") if user_input == "quit": break elif user_input== "add": num1= float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) result= str(num1 + num2) print("Answer -> " + result) elif user_input== "substract": num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) result = str(num1 - num2) print("Answer -> " + result) elif user_input== "multiply": num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) result = str(num1 * num2) print("Answer -> " + result) elif user_input== "divide": num1 = float(input("Enter a number: ")) num2 = float(input("Enter another number: ")) result = str(num1 / num2) print("Answer -> " + result) else: print("Unknown input, sorry try again") This is the error im getting: >>> python 1.py Options Enter 'add' to add two numbers Enter 'substract' to substract two numbers Enter 'multiply' to multiply two numbers Enter 'divide' to divide two numbers Enter 'quit' to end the program Enter your operation:add Traceback (most recent call last): File "1.py", line 9, in <module> user_input = input("Enter your operation:") File "<string>", line 1, in <module> NameError: name 'add' is not defined