Languages
[Edit]
EN

Python - nested dictionary

0 points
Created by:
Joshua-Heath
685

In this article, we would like to show you nested dictionary in Python.

Practical example

Below we present example nested dictionary of users.

users = {
    "user1": {
        "name": "Tom",
        "age": 30
    },
    "user2": {
        "name": "Kate",
        "age": 23
    },
    "user3": {
        "name": "Ann",
        "age": 25
    }
}

You can also create a nested dictionary from existing dictionaries in the following way:

# dictionaries
user1 = {
    "name": "Tom",
    "age": 30
}
user2 = {
    "name": "Kate",
    "age": 23
}
user3 = {
    "name": "Ann",
    "age": 25
}

# nested dictionary
users = {
    "user1": user1,
    "user2": user2,
    "user3": user3
}
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.

Python - dictionary (popular problems)

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