Python - What is the output: variable length argument?

Question

What is the output of the following code?

def func(a, *pargs): 
    print(a, pargs) 

func(1, 2, 3) 


Click to view the answer

1 (2, 3)

Note

1 is passed to a and the *pargs collects the remaining positional arguments into a new tuple object.

We can step through the extra positional arguments tuple with any iteration tool.

Related Quiz