Apr-06-2019, 02:12 PM
I have now commented the values inside the function and left the parameters the way they were.
I am trying to use the same code to calculate A, in other words, how big does A need to be in order
for the n the iteration to be zero or less?
The loop on the last line does not work, it always says that 'return' is out of the function,
even though the indentation looks correct to me.
I am trying to use the same code to calculate A, in other words, how big does A need to be in order
for the n the iteration to be zero or less?
The loop on the last line does not work, it always says that 'return' is out of the function,
even though the indentation looks correct to me.
def f(balance,r,A,n): #r=5.0 #A=1000.0 #n=12 #balance=10000 L=[] for year in range(n): balance=(balance)*(r/100.0 +1)- A L.append(balance) if balance <=0: balance=0 break return L a=len(f(balance,r,A,n)) print(a) b=(f(1000,5,A,20)[a-1]) if b <=0: return A print(A)