Dict Methods

dict.values()

Provides a live view of current dictionary values in insertion order of their associated keys. Repeated or unhashable values are allowed. It supports iteration, length and membership but not indexing or set-like equality. Comparing two separately created values views does not compare their elements; a view compared with itself is identical. Use list(view) for an order-sensitive sequence comparison or Counter for hashable-value frequency comparison. Avoid adding or removing entries while iterating.

Formal Syntax & Structure

python syntaxpython
mapping.values()

Return Value

dict_values

Reusable dynamic view, not a list or set.

Working Example

Example Snippetpython
stock = {"pen": 2, "book": 2}values = stock.values()stock["bag"] = 5print(list(values))print(sum(values))print(values == stock.values())
Python Reference