Back to Lesson

Filtering by Iteration

Cleanse a dictionary of inactive objects.

Instructions

  • Given
    users = {"Alice": False, "Bob": True, "Carol": False, "Dave": True}
    .
  • Create a new dictionary
    active_users = {}
    .
  • Iterate over the original dictionary. If the value evaluates to
    True
    , add that pair to
    active_users
    .
  • Print
    active_users
    .
main.py
main.py