pythonreference.com

search statements, functions, methods, exceptions*

show categories

multiple target assignment
assign multiple values to individual variables
mylist = [1, 2, 3]

a, b, c = mylist    # "unpack" 3 list values

print(b)            # 2
[values in a container] -> [variable names]
Argument(s):
N/A
Return value(s):
N/A
A convenience statement that allows "unpacking" of values from a list, tuple or other ordered container, assigned to individual variable names. The number of variable names on the left must match the number of values on the right, otherwise a ValueError will occur.