Say I create a recursive nested list in Python like this:
>>> a = [1,2]
>>> a += [a]
Some properties:
len(a)
is3
a[2] is a
isTrue
What happens when you print out a
? This appears:
>>> a
[1, 2, [...]]
Similarly:
>>> a[2]
[1, 2, [...]]
Why? How does Python "know" the recursion within the list? How is the recursion detected?