Categories
Python Answers

How to get list of values from dict with Python?

Spread the love

Sometimes, we want to get list of values from dict with Python.

In this article, we’ll look at how to get list of values from dict with Python.

How to get list of values from dict with Python?

To get list of values from dict with Python, we can use the values method.

For instance, we write

list(d.values())

to call d.values to get the values of the dict d in an iterator.

Then we call list to convert the iterator to a list.

Conclusion

To get list of values from dict with Python, we can use the values method.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *