Dynamic arguments for Python functions

399 Views Asked by At

I have a list of lists, and I would like to enter them into a function in such a way that each element of the main list is a different argument to the function.

squares = [[1,5,9,13], [2,6,10,14], [3,7,11,15], [4,8,12,16]]
print zip(squares[0], squares[1], squares[2], squares[3])
# displays [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]]

Is there a way to do something like print zip(arguments(squares)) so that the arguments can be entered dynamically?

1

There are 1 best solutions below

0
On BEST ANSWER

This is what the * operator is for:

print zip(*squares)