26 of 151 menu

The values ​​method

The values method returns all dictionary values. The values ​​are returned as a special object dict_values. We do not specify anything in the method parameter.

Syntax

dictionary.values()

Example

Let's get all the meanings from our dictionary:

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

Result of code execution:

dict_values([1, 2, 3])

Example

Let's get all the values ​​as a list:

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

Result of code execution:

[1, 2, 3]

See also

  • method keys,
    which returns the keys of the dictionary
  • method items,
    which returns the keys and values ​​of a 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