How to convert dictionary values to a list in Python

Converting the values of a dictionary to a list creates a new list where each element is a value from the dictionary. For example, converting the values of {“a”: 1, “b”: 2} to a list results in [1, 2].

Solution for How to convert dictionary values to a list in Python : You can use dict.values() and list() to convert the values of a dictionary to a list Call dict.values() to create a view of the dictionary’s values. Use list(item) with the view of dictionary values as item to return a list.


how-to-convert-dictionary-values-to-a-list-in-python