Следите за новинками
в нашем Telegram канале. Жми, чтобы подписаться:)
17 of 151 menu
◀ ▶

The clear method

The clear method removes all elements from the dictionary. We do not specify anything in the method parameter.

Syntax

dictionary.clear()

Example

Let's remove all the elements in our dictionary:

dct = { 'a': 1, 'b': 2, 'c': 3 } dct.clear() print(dct)

Result of code execution:

{}

See also

  • function len,
    which returns the length of the dictionary
  • method pop,
    which removes an element by its key
  • method popitem,
    which deletes a key-value pair
  • method copy,
    which copies a dictionary
← →
↑
English▼
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline