There is a code. Logically should work, but no. When adding an element in a loop using the append() method append() it rewrites all the elements, and you need to save the results of each iteration. Tried and insert() , and set the function itself in the loop, it does not help. Code example:
def time(lists, var): lists[0] = lists[0]+var return lists time_all = [] lst = [0,1,2,3,4] for i in range(5): time_all.append(time(lst, i)) lst = time_all[i] print(time_all) gives it:
[[10, 1, 2, 3, 4], [10, 1, 2, 3, 4], [10, 1, 2, 3, 4], [10, 1, 2, 3, 4], [10, 1, 2, 3, 4]]
but you must :
[[ 0, 1, 2, 3, 4], [1, 1, 2, 3, 4], [3, 1, 2, 3, 4], [6, 1, 2, 3, 4], [10, 1, 2, 3, 4]]
PS It is necessary lists. It is necessary to change one element in the cycle, but then it passes a series of checks and other elements can change.