Failures you can check for and failures you find by trying

Fill in the blanks · Basic · §13.2 A program that doesn't crash

This code prints the engagement rate (%) of each post. You can check whether the view count is 0 before dividing, but you only find out whether the text in the likes field converts to an integer by trying. Fill in the two blanks. After except, write only the name of the error raised when the text cannot be converted to an integer.

Code with blanks

rows = [("mina", "30", 120), ("jun", "lots", 80), ("sora", "5", 0)]
for name, likes_text, views in rows:
    if ____:
        print(name, "has no views")
        continue
    try:
        likes = int(likes_text)
    except ____:
        print(name, "has likes that are not a number")
        continue
    print(name, likes / views * 100)

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.