1

Problem

print(id([1,2,3,[1,3]]))
hello = [1,2,3]
print(id(hello))

output: 4344840704 4344840704

I don't really understand why those two list have the same id? Thanks

martineau
  • 119,623
  • 25
  • 170
  • 301
  • i think this is the answer - https://stackoverflow.com/a/38189759/6593287 – Sergey K Dec 24 '21 at 14:44
  • @СергейКрылов no, that's about the id of small integers; this is about the ids of two different lists. – Mark Ransom Dec 24 '21 at 14:47
  • Well, The similiar question my post has been associated to doesn't really answer to my question. I found the answer in another post: https://stackoverflow.com/questions/67372886/different-lists-in-python-in-size-and-content-still-share-the-id-does-memory-ma I understand why the same id is printed: The lists don't exist at the same time. ``` hola = id([1,2,3,[1,3]]) hello = [1,2,3] print(id(hola)) print(id(hello)) ``` By doing this, I have now 2 differents ids – saad chraibi Dec 24 '21 at 15:12

0 Answers0