Python Function Reference

dict.values

Access the values of the dictionary.

Python 3.13
dict.values()

Return value

A dict_values view that reflects changes to the dictionary; wrap it in list() to get a list.

Examples

List of dictionary values

Python 3.13
a = {'x': 1, 'y': 2}
print(list(a.values()))
[1, 2]

Sum of the values

Python 3.13
prices = {'apple': 50, 'pear': 70}
print(sum(prices.values()))
120

Details

Unlike keys, values can repeat. The check value in d.values() goes through all values, so it is slower than key in d. Two values views are not compared by contents: d.values() == d.values() gives False, so compare lists instead.

See also

Where to learn