Languages
[Edit]
EN

Python - get dictionary keys

3 points
Created by:
Nataniel-Barclay
499

In this article, we would like to show you how to get dictionary keys in Python.

Quick solution:

my_dictionary.keys()

 

Practical example

In this example, we use keys() method to get the list of my_dict dictionary keys.

my_dict = {
    "id": 1,
    "name": "Tom",
    "age": 25
}
result = my_dict.keys()

print(result)  # dict_keys(['id', 'name', 'age'])

Output:

dict_keys(['id', 'name', 'age'])
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join