Use my_dict.keys() to get a live view of a dictionary’s keys. If you need a separate list, use list(my_dict) or list(my_dict.keys()). To process keys in a loop, iterate over the dictionary directly with for key in my_dict:.
Get a keys view with dict.keys()
The keys() method returns a view connected to the dictionary, not a new list. The view reflects changes made to the dictionary:
person = {"name": "Ada", "language": "Python"}
keys_view = person.keys()
print(keys_view) # dict_keys(['name', 'language'])
Use this form when you want a live view or need to check whether a key is present. For example, "name" in person.keys() checks membership; "name" in person is the shorter equivalent.
The behavior of dictionary key views is documented in the Python 3.14.8 built-in types reference.
#1 Best Overall
Get the keys as a list
Use list(my_dict) for a separate list of keys. It is equivalent to list(my_dict.keys()):
person = {"name": "Ada", "language": "Python"}
keys_list = list(person)
print(keys_list) # ['name', 'language']
The list is a snapshot: later changes to the dictionary do not update it. That makes it useful when you need a list-shaped collection or want to change the dictionary while processing the original keys.
Rank #2
Loop over dictionary keys
A dictionary yields its keys when iterated, so you do not need to call keys() in a loop:
for key in person:
print(key)
This is equivalent to for key in person.keys():. Use direct iteration when you simply want to handle each key.
Key order and changing a dictionary during iteration
Dictionaries preserve insertion order; this became a language guarantee in Python 3.7. As a result, both direct iteration and list(my_dict) yield keys in that order. The official reference also documents reverse iteration over dictionaries and keys views starting in Python 3.8.
Avoid adding or deleting dictionary entries while iterating over its keys view. Such changes may raise RuntimeError or cause the iteration to miss entries. If you need to modify the dictionary as you process keys, iterate over a list snapshot instead:
for key in list(person):
if key == "language":
del person[key]
These ordering, reversal, and iteration details are specified in the official Python built-in types reference.
Quick Recap
Best Value
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.
Free tools Windows power users keep installed
One-click scans. No signup required.




