Can someone please help tell me what is wrong here? The lab is telling me to review whether the code for case n=1 is right. I’m getting the right output for test case n = 1 so I’m not sure what is wrong.
def compound_interest(principle, rate, years):
rate = float(rate)/100
years = int(years)
interest = 0
total_interest = 0
newprinciple = principle
principle = principle
year = 1
while year <= years:
if year == 1:
interest = principle * rate
newprinciple = principle + interest
total_interest = total_interest + interest
year = year + 1
else:
interest = newprinciple * rate
newprinciple = newprinciple + interest
total_interest = total_interest + interest
year = year + 1
print(total_interest)
compound_interest(100,5,1)