Ok, so I'm trying to create a function in Python named calc that can perform the 4 basic arithmetic operations.
def calc(n, num1, num2):
if n == '+':
return num1 + num2
elif n == '-':
return num1 - num2
elif n == 'x':
return num1 * num2
elif n == '/':
return num1 / num2
This is my code so far. So when I execute it like so, I get a syntax error pointing to the number 6, the 3rd argument to be passed.
calc(+ 4 6)
SyntaxError: invalid syntax
Can someone tell me what's wrong? I'm just now learning python and I'm expected to create an Interpreter with loops, conditions, functions and variable assignments so getting stuck on this makes me somewhat frustrated, any help is appreciated.