Languages
[Edit]
EN

Python - get dictionary items

3 points
Created by:
nickkk0
437

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)])
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