Kodewick
Start learning →
Starter←→0 / 100

All the pets

#059StarterDictsNumbers2 min

The pet shop counts its animals in a dict like {"cat": 3, "dog": 2}. Write total_pets(pets) to return how many animals there are in all. For an empty dict, return 0.

Examples
total_pets({"cat": 3, "dog": 2})→5
total_pets({"rabbit": 4, "fish": 10, "bird": 1})→15
main.py
def total_pets(pets):
    total = 0
    # your code here: add up the count of each kind

    return total
Ctrl + Enter runs too
Result

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