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

pythondictionary.values()

Example

Let's get all the meanings from our dictionary:

pythondct = {
  'a': 1,
  'b': 2,
  'c': 3
}

print(dct.values())

Result of code execution:

pythondict_values([1, 2, 3])

Example

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

pythondct = {
  'a': 1,
  'b': 2,
  'c': 3
}

print(list(dct.values()))

Result of code execution:

python[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