Python 3 reference · Dictionary Methods

Python Dictionary values() Method

Return a live view of the dictionary's values, for looping or for functions such as sum() and max().

Python 3 Since 3.0

Syntax

dict.values()

Return value

A dict_values view.

Examples

Aggregate valuesTry it yourself
stock = {"apples": 5, "pears": 3}
print(sum(stock.values()), max(stock.values()))

Output

8 5
Find keys by valueTry it yourself
ages = {"Ada": 36, "Linus": 28}
print(36 in ages.values())
print([n for n, a in ages.items() if a == 36])

Output

True
['Ada']

Version history

VersionChange
Python 3.0Added