⊗pyPmDcLn 91 of 208 menu

Dictionary Length in Python

To find out the length of a dictionary, you should apply the len function:

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

Given a dictionary:

dct = { 'x': 1, 'y': 2, 'z': 3 }

Find out the number of elements in it.

The following dictionaries are given:

dct1 = { 'a': 12, 'b': 34, 'c': 56, 'd': 78, 'e': 90 } dct2 = {}

Add an element to the second dictionary whose key is the name of the first dictionary and whose value is its length.

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