I need to create a list that sums values in ranges from x to x. For example, calculate the sum 2 by 2
myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
listSum = sum(myList)
print(f"Sum of list -> {listSum}")
I want to achieve in the first iteration 1+2, in the next 3+4 until the last list value. I tried with a list compreension but i don't know how to do the sum.
myList = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
list2 = [ sum(i) for i in range(myList[0],len(myList),2)]
print(list2)
I pretend obtain list2 = [3,7,11,15,19]
Can someone help me with this?