I'm trying to create a function that uses the value and the index of the value, starting from 1 to put the values in a function and sums the whole list.
In other words I'm trying to get the present value of a list of cashflows that are not the same, therefor have to calculate the present value of each cash flow and sum them.
This is what I have tried.
cash = [10,10,10,10, 10, 10, 11, 10]
DiscoutRate = 0.12
for (period, value) in enumerate(cash, start=1):
PV = value/((1+DiscountRate)**period)
print(PV)
But I see that the results are not correct, any thoughts?
Note that this solution uses a Generator Expression.
>>> sum(value/((1 + DiscountRate) ** period) for period, value in enumerate(cash, start=1))
50.1287
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With