Reputation: 30
Total newbie here......The return statement in the following code is not passing the value calculated by the function. Does anyone has any ideas ?
def pagos(B,P,r,c):
UB = (B-P)*(1+(r/12))
if (c==12):
print(UB) #This is to establish if UB is actually reaching return statement#
return UB
c +=1
pagos(UB,P,r,c)
P=200
B=10000
r=0.2
c=0
R = pagos(B,P,r,c)
print("Answer :"+str(R))```
9472.628606761953
Answer :None
Upvotes: 0
Views: 63
Reputation: 42678
You forgot to use return
in the recursive call:
def pagos(B,P,r,c):
UB = (B-P)*(1+(r/12))
if (c==12):
print(UB)
return UB
c +=1
return pagos(UB,P,r,c)
Upvotes: 2