PACKING/UNPACKING SEQUENCES
Python supports useful functionality regarding sequence types that simplify the task of assigning variables to values, which can be assigned directly or as the return values of a function. One type is called direct assignment and another type pertains to assigning variables to the return values of a function, both of which are discussed in the following subsections.
Automatic Packing (Direct Assignment)
The following code snippet illustrates direct assignment and is called automatic packing of a tuple:
tens = 10,20,30,40,50
The variable tens in the preceding code snippet is a tuple. Another example of direct assignment is shown here:
x,y,z = range(0,3)
The variables x, y, and z in the preceding code snippet are assigned the values 0, 1, and 2, respectively.
Unpacking Return Values of Functions
The following code block illustrates how to assign variables to the return values of a function:
def myfunc():
  # do various things
  ...