Python‎ > ‎dict‎ > ‎

dict.clear()


Definition
Return with removing all items from D.

Syntax
dict.clear()

Parameters
None

Examples
The method clear the keys and values of dictionary.
>>> dict1=dict(x=3)
>>> dict1.clear()
>>> dict1
{}

The method clear the items of the dictionary.
 >>> x=dict({'VA':3.1, 'DC':2,'NY':5.1, 'CA':4.4})
>>> x.clear()
>>> x
{}
>>>

The method returns with:
 >>> a=dict({'Din': 4, 'John': 2, 'Adil': 3, 'Fen': 1})
>>> a.clear()
>>> a
{}
>>>

Comments