Harold Nelson
4/5/2018
A multiple assignmant statement has a tuple of variables on the left and a sequence of some kind on the right.
The left side of the statement must be a tuple, but the right side might be a list or a string.
Examples of swapping
## (1, 2, 3)
x,y,z = z,x,y
print(t)
# Note that nothing has changed yet because t still refers to the original objects referenced by x, y and z at the time t was created.
# However, the names x, y and z now refer to differnt objects.
## (1, 2, 3)
## (3, 1, 2)
Doodle Make up your own example to illustrate this.
The sequence on the right might be a string. The number of variables on the left must match the length of the string.
Example
## a
## b
## c
The following lines of code will both fail because of mismatches.
## Failing Examples
The right hand side expression might be a list. As always, the number of variables must match the length.
Example
## Tom
## Dick
## Harry
The list might be created by splitting a string on the fly.
## 360
## 574
## 9999
## Joe
## Jones
Doodle Time to try an example yourself.