How to convert dictionary to list in python?
A list is a data-structure, or it can be considered a container that can be used to store multiple data at once. The list will be ordered and there will be a definite count of it.
A dictionary is a set of unordered key, value pairs. In a dictionary, The keys must be unique, and they are stored in an unordered manner.
Here we’ll see some examples to convert dictionary to list in python.
e.g.,
dict = {'A': 10, 'B': 12, 'C': 31} l = list(dict.items()) print(l)
e.g.,
a= {"a": 1, "b": 2} values = a.values() l = list(values) print(l) keys=a.keys() l1=list(keys) print(l1)
This is how we convert dictionary to list in python.
Subscribe
Login
Please login to comment
0 Discussion