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
stock = {"apples": 5, "pears": 3}
print(sum(stock.values()), max(stock.values()))
Output
8 5
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
| Version | Change |
|---|---|
| Python 3.0 | Added |
Related
dict.keys()· Return a live view of the dictionary's keys. Supports len(), in and set operations such as & and |.dict.items()· Return a live view of the dictionary's (key, value) pairs, used to loop over keys and values together.- Python Dictionaries · tutorial