Python Glossary Русский

all Python 3Dictionaries (dict)function

dict.values

iteration

Return a dynamic view of the dict's values.

Syntax

d.values()

Unlike keys(), this view is not set-like: values may repeat and need not be hashable, so &, | and - are unavailable. Membership x in d.values() is a linear scan, while a key lookup is O(1) — if you search by value often, build a reversed mapping instead.

Examples

d = {'a': 1, 'b': 2}
print(list(d.values()))   # → [1, 2]
print(sum(d.values()))    # → 3

See also

Open in the full glossarydocs.python.orgReport an inaccuracy