Change your function to this
def tripleAll(*nums):
...
*nums
will allow you to pass arbitrary number of positional arguments to tripleAll
. All of 'em will be stored in nums
and you can iterate through them:
for trip in nums:
...
*
is called splat operator. It unpacks the elements from an iterable to positional arguments of a function. The simple example
def f(*a):
print('function received these arguments:', a)
f(1, 2, 3) # three arguments
f([1, 2, 3]) # one argument
f(*[1, 2, 3]) # unpack everything from [1, 2, 3] to function arguments
outputs
function received these arguments: (1, 2, 3)
function received these arguments: ([1, 2, 3],)
function received these arguments: (1, 2, 3)