Use print(my_dict) to display a Python dictionary. For nested or wide dictionaries, use pprint.pp(my_dict); to put each key and value on its own line, loop through my_dict.items().
Print a dictionary with print()
Pass the dictionary to Python’s built-in print() function:
person = {"name": "Ada", "age": 36}
print(person)
Output:
{'name': 'Ada', 'age': 36}
The braces and key:value pairs are Python’s representation of the dictionary; this output is not JSON. At an interactive Python prompt, you can also type the dictionary variable by itself to display its representation. Python’s documentation distinguishes str(), intended to be fairly human-readable, from repr(), intended to be interpreter-readable; for dictionaries and many other containers, they look the same. Python input and output documentation
Print each key and value on a new line
Use .items() to iterate over key-value pairs, then format each pair as needed:
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11#1 Best Overall
for key, value in person.items():
print(f"{key}: {value}")
Output:
name: Ada
age: 36
This approach is useful when you want to label values, filter entries, or customize their display. A dictionary contains unique keys paired with values. Python data structures documentation
Pretty-print a nested or long dictionary
For nested data or a long display, Python’s standard-library pprint module formats structures across lines and indents them. Import it, then call pprint.pp():
Rank #2
import pprint
person = {
"name": "Ada",
"details": {"age": 36, "role": "developer"}
}
pprint.pp(person)
The pretty-printer keeps a structure on one line when it fits and wraps it to the available width when necessary. You can set that width explicitly:
pprint.pp(person, width=40)
The pprint.pp() default shown in the Python 3.14 documentation is sort_dicts=False, so dictionary entries are not alphabetically reordered by the pretty-printer. Python 3.14 pprint reference
Print dictionary keys in alphabetical order
Dictionaries preserve insertion order in current Python; that is the order in which keys were added, not necessarily alphabetical order. The language reference documents insertion-order preservation as guaranteed since Python 3.7. Python built-in types documentation
To display entries alphabetically by key, iterate over sorted(person):
for key in sorted(person):
print(f"{key}: {person[key]}")
Alternatively, ask pprint to sort dictionary keys:
pprint.pp(person, sort_dicts=True)
In the Python 3.14 reference, pprint.pp() defaults to sort_dicts=False, while pprint.pprint() defaults to sort_dicts=True. Set the option explicitly when the display order matters, rather than relying on different function defaults. Python 3.14 pprint reference
Quick Recap
Best Value
Choose the display method
| Need | Method | What it does |
|---|---|---|
| Quick inspection | print(d) |
Displays the dictionary’s string representation. |
| Nested or long structure | pprint.pp(d) |
Indents and wraps the formatted structure; width can be configured. |
| One pair per line or custom formatting | for k, v in d.items() |
Lets you label, filter, or format each key-value pair. |
| Alphabetical keys | sorted(d) or pprint.pp(d, sort_dicts=True) |
Sorts keys for display rather than changing the dictionary’s insertion order. |
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.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errors




