Hi,
I shorten the presentation with a for loop inside a list
a = [1,2,3,4,5]
[a[:k][-1]/sum(a[:k]) for k in range(1, len(a)+1)]
Results
[1.0, 0.6666666666666666, 0.5, 0.4, 0.3333333333333333]
It seems too concise to read. Is there any other way to write such as
[x[-1]/sum(x) for x := a[:k] for k in range(1, len(a)+1)]
in order to represent x = a[:k] ? The last statement yields an error message though