Kodewick
Start learning →
Basic←→0 / 80

The bakery shelf

#019BasicComprehensionsDicts4 min

In the evening the bakery updates its chalkboard. The shelf is a dict: name → how many are left. Write still_left(shelf) to return a new dict with only what's still there (more than 0), in the same order. An empty dict gives an empty dict.

Examples
still_left({"bagel": 12, "croissant": 0, "muffin": 3})→{'bagel': 12, 'muffin': 3}
still_left({})→{}
main.py
def still_left(shelf):
    # your code here: a dict comprehension keeping only n > 0
    return {}
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.