Back to Lesson

Nested Dictionary Access

Navigate complex dictionary trees seamlessly.

Instructions

  • Nested dictionary:
    db = {"users": {"u1": {"name": "Alice", "role": "Admin"}, "u2": {"name": "Bob", "role": "User"}}}
    .
  • Access the
    "role"
    of
    "u1"
    and print it.
  • Change the name of
    "u2"
    to
    "Robert"
    by mutating the dictionary in place.
  • Print the new name of
    "u2"
    .
main.py
main.py