How can I convert a dictionary into a list of tuples?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In Python, the standard way to convert a dictionary into a list of key-value tuples is to use dict.items() and wrap the result with list(). That gives you a concrete list where each element is a two-item tuple containing a key and its associated value.
The Basic Conversion
dict.items() returns a dynamic view over the dictionary's key-value pairs. Converting that view to a list produces the tuple structure most people want.
The output is:
Each tuple is (key, value).
Why items() Is the Right Tool
You could build the same result manually with a loop, but items() already exposes exactly the data you need.
That works, but list(scores.items()) is shorter, clearer, and idiomatic.
If You Only Need an Iterator
Sometimes you do not need a list yet. In that case, keep the view object from items() or iterate over it directly.
This avoids creating a new list in memory unnecessarily. Use the full list conversion only when you need indexing, serialization, repeated reuse, or an API that explicitly expects a list of tuples.
Sorting the Result
If you want the tuples in a predictable custom order, sort them after conversion or sort the items directly.
This is useful when you need ranked output or stable presentation order.
Dictionary Order in Modern Python
In modern Python, dictionaries preserve insertion order. That means list(my_dict.items()) reflects the order in which entries were added to the dictionary.
The resulting list keeps the x, y, z order.
That makes the conversion predictable in current Python versions, but you should still sort explicitly if the consumer depends on a specific logical order rather than insertion history.
Variations You May Actually Need
If you only want the keys as one-item tuples:
If you want the values only:
If you want a transformed list of tuples, use a comprehension:
This is often more useful than the raw conversion when the tuples are being prepared for database inserts or charting libraries.
Nested Dictionaries
If the dictionary values are themselves complex objects, the tuples still work the same way:
The second element in each tuple is simply the original value object, even if that value is another dictionary or a list.
Common Pitfalls
The first pitfall is using list(my_dict) and expecting key-value tuples. That expression returns only the keys, because iterating a dictionary yields keys by default.
Another pitfall is assuming items() already returns a list. In Python 3, it returns a view object, which is iterable but not itself a list.
A third pitfall is forgetting the tuple shape. Each element is a two-item tuple, so access patterns should look like pair[0] for the key and pair[1] for the value, or better yet, unpack the tuple directly.
Finally, convert to a list only when you need one. For simple iteration, the items() view is already efficient and readable.
Summary
- The idiomatic conversion is
list(my_dict.items()) - Each result element is a
(key, value)tuple - Use
items()directly when you only need iteration and not a concrete list - Sort the tuples if you need a specific order beyond insertion order
- Avoid
list(my_dict)when you actually want key-value pairs

