Hello Everyone! A simple questions!
alex23
wuwei23 at gmail.com
Thu Jul 25 22:45:54 EDT 2013
On 26/07/2013 12:15 PM, Thanatos xiao wrote:
>>>> values = [0, 1, 2]
>>>> values[1] = values
>>>> values
> [0, [...], 2]
>
> why??
First, it helps if you tell us what you were expecting instead.
In your example, you have a list where you have replaced the 2nd element
with the list itself. The [...] indicates that it is self-referential;
there is no other way for it to display itself, because the contained
reference also refers to itself.
>>> values[1]
[0, [...], 2]
>>> values[1][1]
[0, [...], 2]
>>> values[1][1][1][1][1][1][1][1][1]
[0, [...], 2]
>>> values[1][1][1][1][1][1][1][1][1] is values
True
More information about the Python-list
mailing list