Question: I was attempting the sum of elements of the list. where I have to add the adjacent elements of the list and create a new list and repeat the process until I have the last element which will be the answer. I am able to solve the list of lengths less than 5 but I am not able to generalize the solution for any given list. Help me to solve this problem. below is my starting code:
here is the example;
[general example of the problem](https://i.stack.imgur.com/hxtbp.png)

```
lst=[]
n=int(input())

for i in range(0,n):
 num = int(input())

  lst.append(num)
 print(lst)
 sum1=[]
for i in range(1,len(lst)):
  sum=i+i+1
  sum1.append(sum)

print(sum1)

```

Answer: 
The following seems reasonably simple:

```
n = int(input())
lst = [int(input()) for _ in range(n)]

while len(lst) > 1:
    lst[:] = map(sum, zip(lst, lst[1:]))  # all sums of neighbours
    print(lst)

# Output for 1 2 3 4
# [3, 5, 7]
# [8, 12]
# [20]

```

Some docs:

* [`zip`](https://docs.python.org/3/library/functions.html#zip)
* [`map`](https://docs.python.org/3/library/functions.html#map)
* [`sum`](https://docs.python.org/3/library/functions.html#sum)
Given 2 lists of equal length you could do this:

```
M = [1,2,3]
N = [5,6,7]
print(*map(sum, zip(M,N)))

```