Get All Values from a Dictionary in Python

When I first started working with Python dictionaries more than a decade ago, I often found myself needing to extract just the values.

Sometimes I wanted to analyze customer data stored in a dictionary. Other times, I needed to quickly convert values into a list for further processing.

Over the years, I’ve discovered multiple ways to get all values from a dictionary in Python. Each method has its own use case, and knowing them will make you a more confident developer.

In this tutorial, I’ll walk you through five simple methods to get values from a dictionary in Python. I’ll also share practical examples so you can apply them right away.

Method 1 – Use the values() Method in Python

The most common way to get all values from a dictionary in Python is by using the built-in values() method.

This method returns a view object containing all the values of the dictionary.

# Example: Using values() method in Python
customer_orders = {
    "John": 5,
    "Emma": 3,
    "Michael": 8,
    "Sophia": 2
}

# Get all values
order_values = customer_orders.values()

# Convert to list for easier use
print(list(order_values))

You can see the output in the screenshot below.

python dictionary get values

When I run this code, Python gives me [5, 3, 8, 2]. This is the fastest and most direct way to get dictionary values in Python.

Method 2 – Use a For Loop in Python

Sometimes I prefer using a for loop, especially when I need to process each value while extracting it.

# Example: Using for loop in Python
customer_orders = {
    "John": 5,
    "Emma": 3,
    "Michael": 8,
    "Sophia": 2
}

# Extract values using a loop
values_list = []
for value in customer_orders.values():
    values_list.append(value)

print(values_list)

You can see the output in the screenshot below.

get value from dictionary python

Here, Python returns [5, 3, 8, 2] again, but I also have the flexibility to modify values inside the loop.

Method 3 – Use List Comprehension in Python

As a Python developer, I love list comprehensions because they make the code concise and readable. With just one line, I can extract all values from a dictionary.

# Example: Using list comprehension in Python
customer_orders = {
    "John": 5,
    "Emma": 3,
    "Michael": 8,
    "Sophia": 2
}

# Get all values using list comprehension
values_list = [value for value in customer_orders.values()]

print(values_list)

You can see the output in the screenshot below.

get values from dictionary python

The output is [5, 3, 8, 2]. This method is my go-to when I want clean and Pythonic code.

Method 4 – Use the map() Function in Python

The map() function in Python is another way to extract dictionary values. Although it’s not as common as values(), it can be useful when you want to apply a function to each value.

# Example: Using map() function in Python
customer_orders = {
    "John": 5,
    "Emma": 3,
    "Michael": 8,
    "Sophia": 2
}

# Use map to get values
values_list = list(map(lambda x: x, customer_orders.values()))

print(values_list)

You can see the output in the screenshot below.

python get dictionary values

This gives me [5, 3, 8, 2]. While it looks a bit verbose, it’s powerful when combined with transformations.

Method 5 – Use Dictionary Unpacking in Python

Another modern Python technique is dictionary unpacking. This method is less known but can be handy when you want to quickly flatten values into a list.

# Example: Using dictionary unpacking in Python
customer_orders = {
    "John": 5,
    "Emma": 3,
    "Michael": 8,
    "Sophia": 2
}

# Unpack dictionary values
values_list = [*customer_orders.values()]

print(values_list)

The result is [5, 3, 8, 2]. I use this method when I want a quick one-liner without explicitly calling list().

Bonus Tip – Convert Dictionary Values to a Set in Python

Sometimes, I don’t want duplicate values in my results. In that case, I simply convert the dictionary values into a set.

# Example: Converting values to set in Python
customer_orders = {
    "John": 5,
    "Emma": 3,
    "Michael": 8,
    "Sophia": 2,
    "David": 5
}

# Convert values to set
unique_values = set(customer_orders.values())

print(unique_values)

This returns {2, 3, 5, 8}. Using a set is a quick way to remove duplicates when working with dictionary values in Python.

When Should You Use Each Method?

  • Use values() when you just need values quickly.
  • Use for loops when you want to process values as you extract them.
  • Use list comprehensions for clean and efficient code.
  • Use map() when applying transformations.
  • Use dictionary unpacking for quick one-liners.
  • Use sets when you need unique values only.

Real-World Example – Analyze Sales Data in Python

Let’s say I’m analyzing sales data for a small retail business in the USA. The dictionary contains store names as keys and total sales as values.

# Example: Real-world sales data in Python
sales_data = {
    "New York": 15000,
    "Los Angeles": 12000,
    "Chicago": 18000,
    "Houston": 9500,
    "Phoenix": 12000
}

# Get all sales values
sales_values = list(sales_data.values())

print("All sales values:", sales_values)

# Get unique sales values
unique_sales = set(sales_data.values())
print("Unique sales values:", unique_sales)

This gives me:

All sales values: [15000, 12000, 18000, 9500, 12000]  
Unique sales values: {9500, 12000, 15000, 18000}  

This kind of analysis is very common in Python when working with business data.

Getting all values from a dictionary in Python is simple, but knowing multiple methods makes you more flexible. I’ve shown you five easy ways: values(), for loops, list comprehensions map(), and dictionary unpacking.

Each method has its own benefits, and you can choose the one that best fits your use case. I hope you found this tutorial helpful. Try these methods on your own datasets and see which one feels most natural to you.

You may also read:

51 Python Programs

51 PYTHON PROGRAMS PDF FREE

Download a FREE PDF (112 Pages) Containing 51 Useful Python Programs.

pyython developer roadmap

Aspiring to be a Python developer?

Download a FREE PDF on how to become a Python developer.

Let’s be friends

Be the first to know about sales and special discounts.