Python course answer for Question 48 on Compound Interest


#1

I used the blow code, and it is running successfully. However, when I try to submit my answer i get an error stating " Please keep in mind the edge case" - what does this mean? help please.

def compound_interest(principle,rate,years):
r_rate=float(rate)
y_years=int(years)
i_interest=0
if principle<=0 or rate<=0 or years<=0:
print(i_interest)
else:
for i in range(1,y_years+1):
interest=(principler_rate1)/100
principle = principle + interest
i_interest=interest+i_interest
return i_interest

I AM referring to Pythn Foundations courde , module 48 - http://disq.us/p/27y7jrs


#2

Hi, Tanya.

Here there are 4 main points to solve.

  1. If any one the value is zero, it must return zero. return(0) not print.
  2. we must declare compound_interest=0.0 as float as the local variable of function.

Now you can do it!
If still you get any doubts reply to this thread, I will into it.

All the best!