Master Code
On The Go

Learn. Practice. Build.

Home › Code Snippets › Python › Reference › values()

Python Reference

dict.values()

Return a view of all values in a dictionary. Iterable and dynamic.

Last updated: October 2026

Definition: dict.values() returns a view object containing all the values in the dictionary. The view is dynamic — it reflects changes made to the dict. It is iterable but not indexable.

🎬 Live Example

Five common values patterns. Click any button to see the output.

Input:

                
Output:

            

💡 values() returns a view, not a list. It reflects live changes to the dict.

📝

Basic Syntax

dict.values()

# No arguments
# Returns: dict_values view object
# Dynamic — reflects dict changes
# Iterable but NOT indexable

🎯 Parameters

Parameter Type Description
——Takes no arguments.
1

Basic Usage

d = {"name": "Alice", "age": 30}
d.values()
# dict_values(['Alice', 30])

for value in d.values():
    print(value)
# Alice
# 30
2

Aggregate Values

scores = {"Alice": 85, "Bob": 92, "Cara": 78}

sum(scores.values())     # 255
max(scores.values())     # 92
min(scores.values())     # 78
len(scores.values())     # 3

Pro tip: values() is the go-to for numeric aggregations on dicts.

3

Convert to List

d = {"a": 1, "b": 2}

list(d.values())
# [1, 2]

# Now you can index
list(d.values())[0]
# 1

Note: Values views don't support indexing. Convert to a list first if you need v[0].

4

Dynamic View

d = {"a": 1}
values = d.values()

d["b"] = 2
list(values)
# [1, 2]  ← reflects new value

del d["a"]
list(values)
# [2]
5

Real-World: Grade Report

grades = {
    "Alice": 85,
    "Bob": 92,
    "Cara": 78
}

average = sum(grades.values()) / len(grades)
# 85.0

highest = max(grades.values())
# 92

print(f"Class average: {average:.1f}")
print(f"Highest score: {highest}")

🎯 values vs keys vs items

Method Returns Use when
valuesValues onlyYou need only values
keysKeys onlyYou need only keys
items(key, value) pairsYou need both together

⚠️ Common Mistakes

❓ Frequently Asked Questions

What does dict.values() do in Python?

dict.values() returns a view object containing all the values in a dictionary. The view is dynamic — it reflects changes made to the dict.

Is dict.values() a list?

No. In Python 3, it returns a view object. Wrap it in list() to get an actual list: list(d.values()).

Can I iterate over dict.values()?

Yes. The values view is iterable. Loop directly: for value in d.values().

Can I access values by index?

No. Values views don't support indexing. Convert to a list first: list(d.values())[0].

Does values() reflect changes to the dict?

Yes. The view is dynamic. Adding or removing keys updates the values view automatically.

🎯 What's Next?

← All Python Reference