I want to make a loop, that sums up the first two items of a list, and stores the result in a new list. After that it should take the first three items of the first list and sum up these and store the result in the same list aswell.
What I try to do:
x = [1, 2, 3, 4]
y = []
for i in x:
s = i + (i+1)
y.append(s)
This does not work at all. Because of my bad understanding its hard to get help from google. I hope some might understand my problem.
y = [sum(x[:i]) for i in (2, 3)]ory = [sum(x[:2]), sum(x[:3])]iis not an index, it's the value from the list.