Преобразование значений словаря в список в Python
Чтобы преобразовать значения словаря в список, вы можете использовать метод dict.values(), который возвращает объект dict_values. Этот объект можно повторять, и если вы передадите его конструктору list(), он вернет объект списка со значениями словаря в качестве элементов.
Простой фрагмент кода для преобразования значений словаря в список:
Пример 1: с помощью dict.values()
В следующей программе у нас есть словарь, инициализированный тремя парами ключ:значение. Мы будем использовать метод dict.values() для получения объекта dict_values. Мы передаем метод в качестве аргумента конструктору list(), который возвращает список значений.
Пример 2: с использованием понимания списка
Мы также можем использовать понимание списка, чтобы получить значения словаря как элемента списка.
Пример 3: с помощью цикла For Loop
Если вас не устраивает понимание списка, используйте For Loop. Когда вы перебираете словарь, вы получаете следующий ключ на каждой итерации. Вы можете использовать этот ключ для получения значения. Определите пустой список valuesList для хранения значений и добавления значения пары key:value во время каждой итерации в цикле for.
В этом руководстве мы узнали, как получить значения словаря в виде списка.
Convert Python Dictionary Values to List
To convert Python Dictionary values to List, you can use dict.values() method which returns a dict_values object. This object can be iterated, and if you pass it to list() constructor, it returns a list object with dictionary values as elements.
A simple code snippet to convert dictionary values to list is
Examples
1. Convert dictionary values to a list using dict.values()
In the following program, we have a dictionary initialized with three key:value pairs. We will use dict.values() method to get the dict_values object. We pass dict.values() as argument to list() constructor. list() returns the list of values.
Python Program
Output
2. Convert dictionary values into a list using List Comprehension
We can also use List Comprehension to get the values of dictionary as elements of a list.
Python Program
Output
3. Convert dictionary values into a list using For loop
If you are not comfortable with List comprehension, let us use Python For Loop. When you iterate over the dictionary, you get next key during each iteration. You can use this key to get the value. Define an empty list valuesList to store the values and append the value of key:value pair during each iteration in for loop.
Python Program
Output
Summary
In this tutorial of Python Examples, we learned how to get Dictionary values as List.
How to extract all values from a dictionary in Python?
How do I extract all of the values of d into a list l ?
![]()
15 Answers 15
If you only need the dictionary keys 1 , 2 , and 3 use: your_dict.keys() .
If you only need the dictionary values -0.3246 , -0.9185 , and -3985 use: your_dict.values() .
If you want both keys and values use: your_dict.items() which returns a list of tuples [(key1, value1), (key2, value2), . ] .
For Python 3, you need:
If you want all of the values, use this:
If you want all of the keys, use this:
IF you want all of the items (both keys and values), I would use this:
For nested dicts, lists of dicts, and dicts of listed dicts, . you can use
Big thanks to @vicent for pointing out that strings are also Iterable ! I updated my answer accordingly.
PS: Yes, I love yield . 😉
Call the values() method on the dict.
![]()
If you want all of the values, use this:
![]()
![]()
I know this question been asked years ago but its quite relevant even today.
Code of python file containing dictionary
If you want to print only values (instead of key) then you can use :
This will print only values instead of key from dictionary
Bonus : If there is a dictionary in which values are stored in list and if you want to print values only on new line , then you can use :
How to convert Python Dictionary to a list [9 Different ways]
In this Python tutorial, we will understand how Python convert dictionary to list using examples.
In Python, we can convert dictionary to list in Python using the following 9 methods.
- Using items() Method
- Using keys() Method
- Using values() Method
- Using loop + items() Method
- Using List Comprehension Method
- Using Zip Function
- Using Iteration Method
- Using Collection Method
- Using Map Function
Table of Contents
Python convert dictionary to list
Here we will cover all 9 methods to convert dictionary to list in Python with various examples.
Method 1: By using items() method
In this section, we will understand how to use the items() method to convert a dictionary to a list in Python.
The dict.items() method is used to iterate the elements of the dictionary. Using list() we will get all the items converted into the list.
Example:
- In the above code first, we will create a dictionary by using curly brackets and assign them key-values pairs.
- The con_lis variable needs to be converted into a list so that we can use the list() function and then store the result in the con_lis variable.
Output:

Method 2: By using values() method
The dict.values() method in Python can easily get a list of values and to convert values to a list, we can use the list() function
Example:
Let’s take an example and check how to convert a dictionary to a list
Here is the Screenshot of the following given code

Method 3: By using zip() function
In this example, we can combine the zip(), keys(), and values() methods to convert a dictionary into a list.
To create a list of tuples from a Python Dictionary, we can use the zip() function. The zip() function is mostly used in Python for combining two iterators.
Here is the sample code in Python.
Here is the implementation of the following given code

Method 4: By using keys() method
The keys() method in Python is used to get the list of keys from the dictionary. To get the list of all keys, we can combine the list() function with the keys() method.
Let us look at an example of using methods in Python.
Output:

Method 5: By using list comprehension method
In this method, we will dict.items() method to collect the keys and values from a dictionary. After this, we will use the list comprehension method to form a list out of it.
Here is an example of this implementation in Python.
Check the execution of the following given code

Method 6: By using map() function
The map function will take a function and a sequence as a parameter and it applies that function to the iterable and returns a new list.
In this example, you can combine the map() and list() functions to convert the dictionary into a list.
Source code:
Output:

This is how to convert a dictionary to a list.
Method 7: Using for loop & items() Method
In this method, we will understand the use of for loop and dict.items() method to convert a dictionary to a list in Python
Here, we will first use the for loop to iterate over each item in the dictionary. And then we used the list() function to convert items into a list.
Here is a sample example of this execution in Python.
- In the above example, we defined a dictionary named user which consists of multiple key-value pairs.
- After this, we defined an empty dictionary named user_data. Next, we utilized the for loop and item() method to fetch each key value from the dictionary and append it to the new list.
Here is the final execution of the above Python program.

Method 8: Using Iteration Method
In this section, we will understand how to use iteration and the list() function in Python to convert a dictionary to a list.
The example for the execution of the above Python program is given below.
In the above Python program, we utilized for loop to iterate over each item and used square brackets ([]) to have each key-value pair as a list. In the last, we used the list.append() method to append each key-value pair list into the list.
Here is the final result of the above example.

Method 9: Using collection.namedtuple()
In this method, we will discuss how to convert dictionary to list using collection.namedtuple().
The collection.namedtuple() is a subclass in the Python collection module.
This subclass enables us to define new tuple types, each of which has a named field with a certain type. However, these named tuples are also immutable just like standard tuples in Python.
In this approach, we will convert dictionary key-value pair to named tuple using collection.namedtuple() class. After this, we will store these named tuples into a list.
The example for this approach in Python is given below.
In the example, we are converting the User dictionary to new_list list type value using collection.namedtuple() in Python.
Here is the final result of the above Python program.

Conclusion
So, in this Python tutorial, we understood how to Python convert dictionary to list using the following 9 methods.
- Using items() Method
- Using keys() Method
- Using values() Method
- Using loop + items() Method
- Using List Comprehension Method
- Using Zip Function
- Using Iteration Method
- Using Collection Method
- Using Map Function
You may also like reading the following articles.

I am Bijay Kumar, a Microsoft MVP in SharePoint. Apart from SharePoint, I started working on Python, Machine learning, and artificial intelligence for the last 5 years. During this time I got expertise in various Python libraries also like Tkinter, Pandas, NumPy, Turtle, Django, Matplotlib, Tensorflow, Scipy, Scikit-Learn, etc… for various clients in the United States, Canada, the United Kingdom, Australia, New Zealand, etc. Check out my profile.