0

I have written below code:

dict1 = {7: 'Java', 4: 'JavaScript', 3: 'Python', 1:"C#"}
 
dict2 = dict1
del dict1
 
print(dict2)

My understanding is that both dict1 and dict2 are referring to the same object.

So, when I delete the object using one reference then I should get empty {} dictionary, when printing using another reference.

meallhour
  • 13,921
  • 21
  • 60
  • 117
  • 1
    From the [docs](https://docs.python.org/3/reference/simple_stmts.html#grammar-token-python-grammar-del_stmt): *"Deletion of a name removes the **binding** of that name"*. – trincot May 21 '23 at 15:59

0 Answers0