Languages
[Edit]
EN

Python - get dictionary items

3 points
Created by:
nickkk0
497

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

Quick solution:

my_dictionary.items()

 

Practical example

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

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

print(result)  # dict_items([('id', 1), ('name', 'Tom'), ('age', 25)])

Output:

dict_items([('id', 1), ('name', 'Tom'), ('age', 25)])
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