0

Say I have some variable x=2 and it is stored in 2 lists in different slots:

a=[1,x,3] and b=[x,6,7,8]

When I print a and b I get: a=[1,2,3] and b=[2,6,7,8]

But if I now set x=0, printing a and b still gives a=[1,2,3] and b=[2,6,7,8]

I would like to get: a=[1,0,3] and b=[0,6,7,8]

Is this possible in Python 2.7? If it is, please also describe its limits in terms of other data types, such as sets, arrays, tuples, and so on.

Thank you!

user3433489
  • 911
  • 2
  • 10
  • 24
  • 1
    It's not possible. When you use the variable in an expression, its value is used, it doesn't save a reference to the variable. – Barmar Jan 23 '16 at 00:11
  • I don't often see duplicates of questions that are barely more than half an hour old. – TigerhawkT3 Jan 23 '16 at 00:15

0 Answers0