Python dictionary clear() method
Remove every key.
Syntax
dict.clear()
Parameters
None.
Return value
None
Example
Code
d = {"a": 1, "b": 2} d.clear() print(d, len(d))
Output
{} 0
Related
Learn it step by step in the free lesson Dictionaries & Sets, with exercises that check your answers.