What is the best way to remove all keys from a dictionary without deleting the dictionary?

  1. del dict
  2. dict = {}
  3. dict.clear()
  4. dict.removeAll()
Correct answer dict.clear()

Explanation

`clear()` empties the dictionary without destroying its reference.

Update: Admin added a tag on this question

Topics

By Admin · · 54 views