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 minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallFor most Python code, “convert a dictionary to an array” means make a list of its keys, values, or key/value pairs. Use list(data) for keys, list(data.values()) for values, and list(data.items()) for pairs. If you specifically need a NumPy array, pass the sequence you want to np.array().
Choose what the array should contain
| Result | Expression | What it contains |
|---|---|---|
| List of keys | list(data) or list(data.keys()) |
One dictionary key per element |
| List of values | list(data.values()) |
One value per element, in the same order as its key |
| List of pairs | list(data.items()) |
A (key, value) tuple for each entry |
| NumPy array of values | np.array(list(data.values())) |
An ndarray built from the values sequence |
For example:
data = {"name": "Ada", "age": 36}
keys = list(data) # ["name", "age"]
values = list(data.values()) # ["Ada", 36]
pairs = list(data.items()) # [("name", "Ada"), ("age", 36)]
Python documents list(d) as returning a dictionary’s keys. Choose values() or items() when the keys are not the data you need.
What order will the elements be in?
Dictionary iteration order is insertion order. Python guarantees this behavior from Python 3.7 onward; it does not mean the keys are automatically sorted. If you need sorted keys, request that explicitly, for example with sorted(data). See the Python dictionary documentation.
When a list is enough—and when a view is enough
The results of data.keys(), data.values(), and data.items() are dictionary views, not lists. A view can be iterated directly without making a separate list:
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
for key, value in data.items():
print(key, value)
Use list(...) when you need a materialized list—for example, to index the result or keep a separate snapshot of the current entries. Otherwise, iterating over the view avoids building that list.
When you specifically need a NumPy array
NumPy creates ndarrays from sequences such as lists and tuples. First choose which dictionary contents should become the sequence, then pass that sequence to np.array():
Rank #2
import numpy as np
scores = {"Ada": 98, "Lin": 91}
values = np.array(list(scores.values()))
This creates an array from the values. A sequence of numbers is a natural fit for numeric array operations. Dictionaries, however, can hold arbitrary objects, so mixed values or nested values with irregular shapes may not form the homogeneous, rectangular numeric array a task requires. Decide on the intended representation before converting. See NumPy’s array documentation.
For records or named fields
If the goal is tabular or record-shaped data rather than a simple sequence, a plain list of values may lose the association between field names and data. NumPy supports structured arrays with named fields, but its documentation notes that other projects may be better suited to tabular-data manipulation. See NumPy’s structured-array documentation.
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →What about Python’s built-in typed array?
Python’s standard-library array module provides typed arrays, distinct from both a regular list and NumPy’s ndarray. Use it when its supported primitive types and typed-array behavior suit the program. For ordinary dictionary conversion, the list expressions above are usually the clearest; the module’s documentation also explains how to convert an array.array back to a list. See the Python array module documentation.
Quick Recap
Best Value
Common conversion mistakes
list(data)returns keys, not values. Uselist(data.values())to get values.data.items()is a view, not a list. Wrap it inlist()if you need a materialized list of tuples.- Dictionary order is insertion order, not sorted order. Sort explicitly when that is required.
- A list, a NumPy ndarray, and an
array.arrayare different types. Pick the one your next operation or API expects. - If keys must stay paired with their values, convert
items()rather than extracting only one side.
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.




