Mar-30-2020, 02:54 PM
I have a problem with python 3.x.
I am trying to make a CLI calculator using python 3.x, and tried to use the return statement.
However, even after I use return , it gives me an error that my variables have not been defined.
Does anyone know how to fix this? Here is a snippet of my code:
I am trying to make a CLI calculator using python 3.x, and tried to use the return statement.
However, even after I use return , it gives me an error that my variables have not been defined.
Does anyone know how to fix this? Here is a snippet of my code:
def getNum(): #ask for two numbers and then return to function
n1 = int(input("Please enter the first number: "))
n2 = int(input("Please enter the second number: "))
return n1, n2
def multi(): #multiplication
getNum()
print("\nThat equals...")
print(n1 * n2)
multi()
