What is the values() method in Python?

The values() method in Python returns the values of a dictionary.

Syntax

The syntax of this function is as follows:


dict.values()

Parameters and return value

The values() method does not take any parameter.

The return value is a dict_value type that contains the values of the dictionary.

Code

In the example below, the values() function gives the values (‘1,2,3’) of the ‘dictionary’.

dictionary = { 'A': 1, 'B': 2, 'C': 3 }
# dictionary values
dictValues = dictionary.values()
print(dictValues)

Free Resources