I want to use the last element of a list in a for loop to generate new element. Here is a toy example of my problem:
a = [1]
a += [a[-1]+i for i in range(10)]
but it only consider 1 as last element and does not go through for loop to find the new last element. Could you please tell me how to solve this problem?