I have to write a simple function that takes variable number of arguments and prints the sum, something simple like(ignoring error checks):
def add(*params):
sum = 0
for num in params:
sum += num
print(sum)
I have to call the script and give it arguments that will then be used in the function. I get these arguments like this:
import sys
sys.argv[1:]
But that's an array and sending it to add
would just mean passing 1 argument that is a list. I'm new to Python so maybe all of this sounds stupid, but is there any way to pass these arguments to the function properly?