Python dict.values() Method

Beginner
6 min read
Updated: Nov 2026
3 examples
dict method

Definition

values() returns a view of the dict's values, printed as dict_values([...]), in the same order as the keys. Like the other views it is live: later changes to the dict show up in it.

Values can repeat and do not have to be hashable, so a values view is not set-like. It is made for aggregating and scanning: sum(), max(), min(), counting, and in tests.

dict.values() is an instance method of the built-in dict type: call it on a dictionary with dot notation, such as expenses.values(...). No import is needed.

Syntax

Call it with no arguments and hand the view to a loop or an aggregate function.

python
view = d.values()
total = sum(d.values())
CallWhat it does
{"a": 1, "b": 2}.values()Returns dict_values([1, 2]).
sum({"a": 1, "b": 2}.values())Returns 3.
2 in {"a": 1, "b": 2}.values()Returns True.

A values view has no -, &, |, or ^; using them raises TypeError. Convert with set(d.values()) when you need unique values.

Method signatures
python
dict.values()
# returns: a dict_values view of the dict's values

Parameters

values() takes no parameters.

Return Value

Return ValueDescription
dict_valuesA live, read-only view of the values in insertion order. It supports len(), in, iteration, and reversed() (Python 3.8+).

Python Examples

Example 1 — Total a Monthly Budget

Sum the expenses, find the largest and smallest, and work out each category's share in percent.

python
expenses = {"rent": 1200, "food": 450, "transport": 90, "fun": 160}
amounts = expenses.values()

print(amounts)
print(sum(amounts), max(amounts), min(amounts))
print(round(sum(amounts) / len(amounts), 1))
print([round(a / sum(amounts) * 100) for a in amounts])

How It Works

  1. Values only. The view holds the four amounts in category order; the names stay in the dict.
  2. Aggregates accept views. sum(), max(), and min() iterate the view directly: 1900, 1200, and 90.
  3. Average. 1900 / 4 is 475.0; true division always gives a float, so round() keeps one decimal.
  4. Reuse the view. The comprehension walks the same view again to turn each amount into a whole-number percentage of the total.

Example 2 — Tally Lunch Votes and Find Unique Choices

Values may repeat. Count them, list the distinct ones, and see why set operators fail on a values view.

python
votes = {"Ana": "pizza", "Ben": "tacos", "Cy": "pizza"}
choices = votes.values()

votes["Dee"] = "sushi"
print(len(choices), "pizza" in choices)
print(list(choices).count("pizza"))
print(sorted(set(choices)))
try:
    print(choices & {"pizza"})
except TypeError:
    print("values views do not support set operations")

How It Works

  1. Live length. Dee voted after the view was made, and the view still counts four votes.
  2. Repeats allowed. Two people chose pizza; list.count() on a list copy finds both.
  3. Distinct choices. set() drops the duplicate pizza and sorted() gives a stable order to print.
  4. Not set-like. & on a values view raises TypeError, unlike keys and items views.

Example 3 — Apply a Discount and Compare Values Correctly

Rewrite every price in place, read the updated values through an earlier view, then compare two dicts' values the right way.

python
prices = {"book": 20.0, "pen": 2.5, "bag": 35.0}
vals = prices.values()

for item in prices:
    prices[item] = round(prices[item] * 0.9, 2)
print(list(vals))
print(prices)

twin = dict(prices)
print(prices.values() == twin.values())
print(sorted(prices.values()) == sorted(twin.values()))

How It Works

  1. Assign through keys. A values view is read-only, so the loop writes each new price with prices[item] = .... Replacing values of existing keys during the loop is allowed.
  2. Old view, new numbers. vals was created before the loop yet lists the discounted prices.
  3. Identity trap. Two values views are never equal, even with identical contents, so the first comparison prints False.
  4. Compare contents. Sorting both into lists compares the actual numbers and prints True.

Frequently Asked Questions

A dict_values view of the values in insertion order. It updates itself when the dict changes; wrap it in list() for a fixed copy.
Use sum(d.values()). max(d.values()) and min(d.values()) find the largest and smallest values.
Use value in d.values(). It scans the values one by one, so for frequent checks on large dicts keep a separate set.
Values views are compared by identity, and each call creates a new view object. Compare list(a.values()) == list(b.values()) instead.
Loop over the items: [k for k, v in d.items() if v == target]. Several keys can share a value, so you may get more than one.

Back to the method index

See all 11 dict method guides grouped by what they do.

Method Index →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful