Kodewick
Start learning →
Starter←→0 / 80

Pet ages in months

#016StarterComprehensionsDicts3 min

The vet's chart has each pet's age in years: {"Mochi": 2}. Write in_months(pets) to return a new dict with a dict comprehension: same names, ages in months (times 12). An empty dict gives an empty dict.

Examples
in_months({"Mochi": 2, "Tofu": 5})→{'Mochi': 24, 'Tofu': 60}
in_months({})→{}
main.py
def in_months(pets):
    # your code here: a dict comprehension, same name, age times 12
    return {}
Ctrl + Enter runs too
Result

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