Diclaimer
I did it just out of curiosity, and than decided that since I've already spent my time on it, I would post it. I still support the point that OP should have invested more effort into this, and I've voted to close the question.
Anyway:
list(map(lambda x: x[0]+x[1], zip(a[::2], a[1::2])))
a[::2]
is list slicing syntax. a[::2]
means "take every second element starting from first", a[1::2]
means "take every second element starting from second"
zip
zips two sequences together:
>>> a = [1,2,3]
>>> b = [4,5,6]
>>> list(zip(a,b))
[(1, 4), (2, 5), (3, 6)]
map
applies function to every item in an interable
>>> a = [1,2,3]
>>> list(map(lambda x: x+1, a))
[2, 3, 4]
lambda
is python lambda notation. It's a shortcut to create anonymous function.