Python - Multiple-Target Assignments


A multiple-target assignment assigns all the given names to the object all the way to the right.

The following code assigns the three variables a, b, and c to the string 'test':


a = b = c = 'test' 
print( a, b, c )


This form is equivalent to (but easier to code than) these three assignments:

c = 'test' 
b = c 
a = b 

Related Topic