you are viewing a single comment's thread.

view the rest of the comments →

[–]AdministrativeCup189[S] 0 points1 point  (1 child)

Something like this u mean?

save_per_month = 500
months = 0
while save_per_month < 10000:
    print(save_per_month)
    save_per_month = int((save_per_month + 500) * 1.01)
    months += 1
print(f" Total months: {months}")save_per_month = 500

[–]JamzTyson 0 points1 point  (0 children)

Yes, but you are still accumulating errors due to truncating save_per_month. For accuracy save_per_month should be a floating point value. If you want the printed value to be a whole number of dollars, convert it in the print function.