explain the difference between del and clear in dictionary with an example
Answers
Answered by
7
Answer:
clear() removes every key, so basically their behavior is the same. On the memory issue, in Python when you "delete" you are basically removing a reference to an object. ... clear() will free the memory of the hashset used in the dict, while removing the key will not.
Similar questions