Back to Lesson

Filter Dictionaries

Incorporate `if` assertions deeply within comprehensions.

Instructions

  • Given
    inventory = {"swords": 5, "shields": 0, "potions": 12, "maps": 0}
    .
  • Build a new dictionary preserving only items that have an inventory score greater than 0.
  • Print the filtered array mappings.
main.py
main.py