I cannot get the expected result

You should get rid of the eval and replace it with an int or float depending on whether the interest rate or integer or not:

I = float(input("Enter your annualized interest rate: "))

then divide the percentage by 100:

z = z * (1 + I / 100.0)

You also don’t need the last if statement as z will always be larger than or equal to 2 to get out of the while loop.

Leave a Comment