I have a price list where I am trying to calculate the change as a percentage of each number. I calculated the differences with
prices = [30.4, 32.5, 31.7, 31.2, 32.7, 34.1, 35.8, 37.8, 36.3, 36.3, 35.6] def f(): for i in range(len(prices)): print(prices[i]-prices[i-1])
Which returns the differences, for example
2.1 -0.8 -0.5 ...
I know that the percentage change will be ((ii-1)) / (i-1) * 100, but I don't know how to include it in the script. Any help would be much appreciated.
python
user1709173
source share