13.5. Unpacking Tuples as Arguments to Function Calls

Python even provides a way to pass a single tuple to a function and have it be unpacked for assignment to the named parameters.

This won’t quite work. It will cause an error, because the function add is expecting two parameters, but you’re only passing one parameter (a tuple). If only there was a way to tell python to unpack that tuple and use the first element to assign to x and the second to y.

Actually, there is a way.

Don’t worry about mastering this idea yet. But later in the course, if you come across some code that someone else has written that uses the * notation inside a parameter list, come back and look at this again.

You have attempted of activities on this page