Skip to content

Instantly share code, notes, and snippets.

@leangaurav
Created May 11, 2019 15:27
Show Gist options
  • Save leangaurav/3ca80697771a0d9ce624f42dbb8582d6 to your computer and use it in GitHub Desktop.
Save leangaurav/3ca80697771a0d9ce624f42dbb8582d6 to your computer and use it in GitHub Desktop.
l1 = [[10,20,30], 1, 2, 3]# a list with another list at index 0
l2 = list(l1)             # create a copy

l1.append(4)              # append to list l1
l1[0].append(40)          # modify the inner list of l1

print( id(l1[0]) )
print( id(l2[0]) )

Output
3121053638984
3121053638984

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment