How to Get All Values from a Dictionary in Python
If you want all values from a Python dictionary, the simplest solution is to use dict.values().
This page shows you:
- How to get all values from a dictionary
- What
dict.values()returns - When to convert the result to a list
- How to loop through dictionary values
Quick answer
person = {"name": "Ana", "age": 25, "city": "Lima"}
values = person.values()
print(values)
print(list(values))
Output:
dict_values(['Ana', 25, 'Lima'])
['Ana', 25, 'Lima']
Use dict.values() to get all dictionary values. Convert it with list() if you need a regular list.
What this page helps you do
- Get all values from a dictionary
- Understand what
dict.values()returns - Convert dictionary values to a list when needed
- Loop through dictionary values
Use values() to get all values
Call values() on a dictionary object.
student = {"name": "Maya", "grade": "A", "age": 16}
values = student.values()
print(values)
Output:
dict_values(['Maya', 'A', 16])
This is the standard way to get dictionary values in Python.
A few important points:
values()returns the values only- It works with strings, numbers, lists, and other Python objects
- It does not return the keys
If you want to understand the method itself in more detail, see the dict.values() method reference.
Convert values to a list
Sometimes you need a regular list instead of a dictionary view. In that case, wrap the result in list().
student = {"name": "Maya", "grade": "A", "age": 16}
value_list = list(student.values())
print(value_list)
Output:
['Maya', 'A', 16]
Use list(my_dict.values()) when you need:
- A list you can print more clearly
- A value at a specific position
- To pass the values to code that expects a list
Example:
student = {"name": "Maya", "grade": "A", "age": 16}
value_list = list(student.values())
print(value_list[0])
print(value_list[1])
Output:
Maya
A
The order follows the dictionary insertion order.
If you also need the keys, see how to get all keys from a dictionary in Python.
Loop through all values
If you want to process each value, loop through my_dict.values().
prices = {"apple": 2, "banana": 1, "orange": 3}
for value in prices.values():
print(value)
Output:
2
1
3
Each loop gives you one value.
This is useful when you want to:
- Print all values
- Check each value
- Do calculations or other processing
For example:
prices = {"apple": 2, "banana": 1, "orange": 3}
for value in prices.values():
if value > 1:
print("Greater than 1:", value)
Output:
Greater than 1: 2
Greater than 1: 3
Do not loop over the dictionary directly if you only want values. Looping over a dictionary by itself gives you the keys.
prices = {"apple": 2, "banana": 1, "orange": 3}
for item in prices:
print(item)
Output:
apple
banana
orange
If you want more examples, see how to loop through a dictionary in Python.
Understand the result of values()
A common beginner mistake is expecting values() to return a list.
It does not.
It returns a view object linked to the dictionary. That means it reflects changes made to the dictionary.
person = {"name": "Ana", "age": 25}
values = person.values()
print(list(values))
person["city"] = "Lima"
print(list(values))
Output:
['Ana', 25]
['Ana', 25, 'Lima']
Notice that values changed after the dictionary changed.
If you need a separate snapshot that does not change, convert it to a list.
person = {"name": "Ana", "age": 25}
value_list = list(person.values())
print(value_list)
person["city"] = "Lima"
print(value_list)
Output:
['Ana', 25]
['Ana', 25]
This difference matters when you plan to store the result and use it later.
If you want a broader explanation of dictionaries, see Python dictionaries explained.
When to use this vs other dictionary methods
Use the dictionary method that matches the data you need:
- Use
values()for values only - Use
keys()for keys only - Use
items()for both keys and values together
Example:
person = {"name": "Ana", "age": 25, "city": "Lima"}
print(person.keys())
print(person.values())
print(person.items())
Output:
dict_keys(['name', 'age', 'city'])
dict_values(['Ana', 25, 'Lima'])
dict_items([('name', 'Ana'), ('age', 25), ('city', 'Lima')])
Use items() when you need both parts together in a loop:
person = {"name": "Ana", "age": 25, "city": "Lima"}
for key, value in person.items():
print(key, "->", value)
If that is what you need, see the dict.items() method reference.
Common mistakes
These are the most common problems beginners run into.
Using the dictionary directly and getting keys instead of values
This gives keys, not values:
person = {"name": "Ana", "age": 25}
for item in person:
print(item)
Output:
name
age
If you want values, use:
for value in person.values():
print(value)
Expecting values() to return a list
This is a view object:
person = {"name": "Ana", "age": 25}
print(person.values())
print(type(person.values()))
Output:
dict_values(['Ana', 25])
<class 'dict_values'>
Convert it if needed:
print(list(person.values()))
Trying to access values by index without converting first
This will fail:
person = {"name": "Ana", "age": 25}
values = person.values()
# print(values[0]) # TypeError
Instead, do this:
person = {"name": "Ana", "age": 25}
values = list(person.values())
print(values[0])
Mixing up keys(), values(), and items()
Remember:
keys()→ keys onlyvalues()→ values onlyitems()→ key-value pairs
If you need help getting a single value or working with dictionary data, see how to access values in a dictionary in Python.
FAQ
How do I get all values from a dictionary in Python?
Use my_dict.values(). If you need a list, use list(my_dict.values()).
Does values() return a list?
No. It returns a dictionary view object. Convert it to a list if needed.
Can I loop through dictionary values only?
Yes. Use:
for value in my_dict.values():
print(value)
Can I index dictionary values like values[0]?
Not directly from values(). Convert first with list(my_dict.values()).