79448225

Date: 2025-02-18 12:24:01
Score: 1.5
Natty:
Report link

Sets themselves are NOT mutable, even if their contents are. See code below. After line 2, y points to the contents of x. But because the set changes in line 4, it has to be destroyed and a new one is made. That is why afterwards, y no longer points to the contents of x but to the ORIGINAL set that was held by x. x = set(['a','b','c']) y = x print(x is y) x = set(['a','b','c','d']) print(x is y) print(y)

Reasons:
  • No code block (0.5):
  • Low reputation (1):
Posted by: Philip Lafeber