Back to Lesson

Configuration Fallback

Use the safe lookup features in dictionaries.

Instructions

  • Given
    user_config = {"theme": "light"}
    .
  • Print the user's
    "timezone"
    using
    .get()
    with a fallback of
    "UTC"
    .
  • Then use
    .setdefault()
    to set the
    "theme"
    to
    "dark"
    (which handles exiting keys) and
    "language"
    to
    "en"
    .
  • Print the resulting
    user_config
    dictionary.
main.py
main.py