python: точечная сумма списка

Input: two lists (list1, list2) of equal length
Output: one list (result) of the same length, such that:
    result[i] = list1[i] + list2[i]

Есть какой-нибудь краткий способ сделать это? Или это лучший вариант:

# Python 3
assert len(list1) == len(list2)
result = [list1[i] + list2[i] for i in range(len(list1))]
5
задан max 26 April 2011 в 09:34
поделиться