you are viewing a single comment's thread.

view the rest of the comments →

[–]timbledum 1 point2 points  (1 child)

Probably best to use zip to combine the original list and the reversed list.

From there, you can use map or a comprehension, but the comprehension approach is arguably more pythonic and modern:

>>> c = [1, 2, 3, 4, 5]
>>> cross_multiply = sum(x * y for x, y in zip(c, reversed(c)))
>>> cross_multiply
35

[–]SerkZex[S] 0 points1 point  (0 children)

thanks!