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

The update method

The update method supplements the original dictionary with keys and values ​​of another dictionary. In the method parameter, we specify the dictionary with which we will supplement the original one.

Syntax

dictionary.update(dictionary to supplement the original)

Example

Let's update our dictionary using the update method:

dct1 = { 'a': 1, 'b': 2, 'c': 3 } dct2 = { 'e': 4, 'f': 5 } dct1.update(dct2) print(dct1)

Result of code execution:

{'a': 1, 'b': 2, 'c': 3, 'e': 4, 'f': 5}

See also

  • method copy,
    which copies a dictionary
  • method clear,
    which deletes all elements of the dictionary
  • function len,
    which returns the length of the 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