How to assign multiple values to a same variable in Python?

In Python, if you try to do something like

a = b = c = [0,3,5]
a[0] = 10

You'll end up with the same values in

a, b, and c: [10, 3, 5]

This is because all three variables here point to the same value. If you modify this value, you'll get the change reflected in all names, ie, a,b and c. To create a new object and assign it, you can use the copy module. 


a = [0,3,5]
import copy
b = copy.deepcopy(a)
a[0] = 5



This will give the output −