A false message left by a wide net

Predict the output · Medium · §13.6 [Pair coding with AI] Asking to add exception handling

You had a function that computes the follower growth rate (%). You asked an AI, "Fix it so that no errors happen," and got this code. Predict the output without running the code.

Code

def growth(before, after):
    try:
        return (after - before) / before * 100
    except:
        print("The previous value is 0")
        return 0

print(growth(200, 250))
print(growth(0, 30))
print(growth(150, None))

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.