I have the following statesments:
A = "s"
B = ["1", "2", "3"]
I want to get the object "A" when I am printing B[2], e.g: print(B[2]), and the answer will give me "A" with a reference to the value of A..
How can I do it in python?
Any suggestion would be appreciated
Thank you all.
The same question in another manner:
I have seen this in the forum:
>>>foo = 'a string'
>>>id(foo)
4565302640
>>> bar = 'a different string'
>>> id(bar)
4565321816
>>> bar = foo
>>> id(bar) == id(foo)
True
>>> id(bar)
4565302640
But if I have:
>>> foo = "a string"
>>> id(foo)
36591240
>>> bar = ["1", "2", "3"]
>>> id(bar)
39186840
>>> bar[2] = foo
>>> id(bar) == id(foo)
Flase
How can I assign a value in a list to match a different obect?
Ain the list?B = ["1", "2", A]Ain the list does not in any way preventAfrom being "an object of its own".