Languages
[Edit]
EN

Python - nested dictionary

0 points
Created by:
Joshua-Heath
505

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
}

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