Dict to List — How to Convert a Dictionary to a List in Python

Summary: To convert a dictionary to a list of tuples, use the dict.items() method to obtain an iterable of (key, value) pairs and convert it to a list using the list(…) constructor: list(dict.items()). To modify each key value pair before storing it in the list, you can use the list comprehension statement [(k’, v’) for k, v in dict.items()] replacing k’ and v’ with your specific modifications.

In my code projects, I often find that choosing the right data structure is an important prerequisite to writing clean and effective code. In this article, you’ll learn the most Pythonic way to convert

Continue reading the original article