Menu Close

How to get list of values from dict with Python?

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.

Posted in Python, Python Answers