Bond CF for loop and if else loop
问题 I am trying to add the last cash flow back into the par value using a if/else loop, but I can't seem to do it. How do I assign an int to a specific item in the range? I am trying to make it so if the index > 10, it will add the par value back in. par = 1000 coupon_rate = 3 T = 5 freq = 2 def cf_calculator(par, r, T, freq): for i in range(T * freq): if (T) < (T * freq): coupon = (r/100) * par/freq print(coupon) else: coupon = (r/100) * par/freq + par print(coupon) print(cf_calculator(1000,3,5