How to add two consecutive number in the list.
l = [1,2,3,4,5,6,7,8,9]
result = [3,7,11,15,9]
l = [1,2,3,4,5,6,7,8,9,10]
result = [3,7,11,15,19]
I can easily achieve it using simple for loop. But
How can I achieve it using more pythonic way.
returns awaited values for both odd and even numbers:
UPDATE: if the original list is really large, you can replace the simple slices with
islice:UPDATE 2: even a shorter and more universal version (without itertools) comes here: