I have a list of elements like [1,3,5,6,8,7].
I want a list of sums of two consecutive elements of the list in a way that the last element is also added with the first element of the list.
I mean in the above case, I want this list:
[4,8,11,14,15,8]
But when it comes to the addition of the last and the first element during for loop, index out of range occurs. Consider the following code:
List1 = [1,3,5,6,8,7]
List2 = [List1[i] + List1[i+1] for i in range (len(List1))]
print(List2)