In this article we will discuss how to create a list of all the values in dictionary.

Suppose we have a dictionary of string and integers i.e.

Now we want all the Values from above dictionary in a list i.e.

Let’s see how to do that,

Create a list of all values in dict using dict.values()

In python, dictionary class provides a member function i.e.

It returns a view object / iterator to the list of all values in dictionary.  We can use this object for iteration or creating new list.

Let’s use that to get the list of all values in the above dictionary.

dictValues content will be,

Creating a list of duplicate values in dictionary

Suppose instead of all values we want a list of all duplicate values from the dictionary i.e.

[23 , 2]

Let’s do that using for loop i.e.

dictkeys content will be,

Top 5 online Python courses for beginners in 2019- 2020

Complete example is as follows,



Python Recommendations:

C++ & C++11 Recommendations:

If you didn't find what you were looking, then do suggest us in the comments below. We will be more than happy to add that.

Subscribe with us to join 1500+ Python & C++ developers, to get more Tips &  Tutorials like this.