Remove all elements from a dictionary
Remove all elements from a dictionary
The clear
method removes all elements
from a dictionary. It does the remove
in place and returns nothing.
d = {} # w ww .ja v a 2s . c om
d['name'] = 'java2s.com'
d['age'] = 42
print d
returned_value = d.clear()
print d
print returned_value
The code above generates the following result.