I have been working on this bit of code and every time I run it it says that result was not defined.
Error: Traceback (most recent call last):
File "/Users/Bubba/Documents/Jamison's School Work/Programming/Python scripts/Ch9Lab2.py", line 24, in <module>
print(str(numberOne) + " " + operation + " " + str(numberTwo) + " = " + str(result))
NameError: name 'result' is not defined
Original Code:
def performOperation(numberOne, numberTwo):
if operation == "+":
result = numberOne + numberTwo
if operation == "-":
result = numberOne - numberTwo
if operation == "*":
result = numberOne * numberTwo
if operation == "/":
result = numberOne / numberTwo
numberOne = int(input("Enter the first number: "))
numberTwo = int(input("Enter the second number: "))
operation = input("Enter an operator (+ - * /): ")
performOperation(numberOne, numberTwo)
print(str(numberOne) + " " + operation + " " + str(numberTwo) + " = " + str(result))