Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk2 min

How to Convert a Dictionary to a List of Tuples in Python

Use list(my_dict.items()) to get a list of (key, value) tuples from a Python dictionary, with examples of reversed pairs, sorting, and iteration order.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use list(my_dict.items()) to turn a Python dictionary into a list of (key, value) tuples. For example, {"apple": 3, "banana": 5} becomes [('apple', 3), ('banana', 5)].

Convert a dictionary to key-value tuples

The dictionary method .items() provides a view of its (key, value) pairs. Wrapping that view in list() creates a list containing those pairs:

As an Amazon Associate I earn from qualifying purchases.

my_dict = {"apple": 3, "banana": 5}
pairs = list(my_dict.items())
print(pairs)
# [('apple', 3), ('banana', 5)]

The official Python Built-in Types reference defines dict.items() as returning “a new view of the dictionary’s items ((key, value) pairs).”

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Why not use list(my_dict)?

Iterating over a dictionary directly yields its keys, so list(my_dict) returns a list of keys—not key-value tuples. Use .items() when each element needs both the key and its value.

keys = list(my_dict)             # ['apple', 'banana']
pairs = list(my_dict.items())   # [('apple', 3), ('banana', 5)]

What order will the tuples have?

For Python 3.7 and later, dictionary iteration order is guaranteed to match insertion order, so the list follows the order in which entries were added. Python 3.6 had this behavior in CPython as an implementation detail, but it was not yet a language guarantee. The Python documentation explains the distinction in its Functional Programming HOWTO.

Choose a different output when needed

Get only keys or values

  • list(my_dict) returns the keys.
  • list(my_dict.values()) returns the values.

Reverse each tuple

To make each tuple (value, key) instead, unpack each item and rebuild it in the desired order:

value_key_pairs = [(value, key) for key, value in my_dict.items()]

Sort the pairs

The basic conversion preserves dictionary iteration order; it does not sort the results. Use sorted() when you want a sorted list:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sorted_pairs = sorted(my_dict.items())  # Sort by key
by_value = sorted(my_dict.items(), key=lambda item: item[1])

The first example sorts by key using the pairs’ natural ordering. The second explicitly sorts by each pair’s value.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

View versus list: when to materialize the pairs

my_dict.items() returns a dynamic view, not a list. The view reflects changes to the dictionary; list(my_dict.items()) creates a materialized list of pairs at the time of conversion. If you need a standalone list to pass elsewhere or modify independently, use list().

Avoid adding or deleting dictionary entries while iterating over an items view. Such changes may raise RuntimeError or cause the iteration not to cover every entry. If you need to change the dictionary while processing its entries, iterate over a list made beforehand, such as list(my_dict.items()).

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.