when I create a list, I use the one-liner
new_list = [func(item) for item in somelist]
Is there a simple way to write the following iteration in one line?
new_list = [0]
for _ in range(N):
new_list.append(func(new_list[-1]))
or even
new_list = [0]
for t in range(N):
new_list.append(func(t, new_list[-1]))
i.e. each item is calculated based on the previous item with a specific initializer.