I am trying to develop a simple calculator function in python where the function signature can take more than 2 nos, default operation will be ADD and default output format would be float.
def calculator(operation=ADD,output=float,*args):
Basically the function should apply the operation to the first two numbers, and then apply it again to the result and the next number, and so on. For example, if the numbers are 6, 4, 9 and 1 and the operation is subtraction the function should return 6 - 4 - 9 - 1.
However when I call the function with:
calculator(1,2,3,4,operation=ADD,output=float)
I get an error:
TypeError: calculator() got multiple values for argument 'operation'
Can someone please tell me how should i invoke this function with right set of parameters?