Skip to content

Instantly share code, notes, and snippets.

@encolpe
Created January 5, 2017 08:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save encolpe/e8f0f2a545879f5441095064e6dfcbeb to your computer and use it in GitHub Desktop.
Save encolpe/e8f0f2a545879f5441095064e6dfcbeb to your computer and use it in GitHub Desktop.
What happen if you're append a list to itself in python?
#!/bin/python
a = [1, 1, 1]
b = a
print(b)
b.append(a)
print(b)
print(b[-1])
print(b[-1][-1])
c = b
while len(c):
print(c)
c = c[-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment