Why do I get [...] when I append a list to the same list in python? -


the following code tried in python 2.7.1 interpreter.

>>> = [1, 2, 3] >>> a.append(a) >>> [1, 2, 3, [...]] >>> == a[-1] true >>> print a[-1] [1, 2, 3, [...]] 

can please explain python trying here?

you have created infinite nested list inside list. can not represented, [...] appears.

take @ happens if try print each value:

>>> item in a: ...     print item ...  1 2 3 [1, 2, 3, [...]] # whole list iterated on :) 

refer here further reading.


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -