The message caught with as e

Predict the output · Medium · §13.3 What to catch

This code prints the average number of likes per post. Predict the output without running the code.

Code

likes = {"mina": 120, "jun": 30, "sora": 90}
posts = {"mina": 4, "jun": 0, "sora": "3"}
for name in ["mina", "jun", "dami", "sora"]:
    try:
        print(name, likes[name] / posts[name])
    except ZeroDivisionError as e:
        print(name, "failed:", e)
    except KeyError as e:
        print(name, "failed:", e)
print("Done")

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.