statements operators functions string methods set methods tuple methods dict methods file methods list methods exceptions exception types comprehensions multidimensionals os lambdas subprocess
Intro to Python

Session 1 Session 2 Session 3 Session 4 Session 5 Session 6 Session 7 Session 8 Session 9




pythonreference.com

search statements, functions, methods, exceptions*

hide 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.