#!/usr/bin/python3 nums = [1, 2, 3, 4] print(sum(nums )) # 10 print(sum(nums, 5)) # 15
zip
to sum up the pairwise multiplication of elements of two lists. 34
, which is 1*2 + 5*4 + 4*3
: x = [1, 5, 4] y = [2, 4, 3] p = sum(x*y for x,y in zip(x,y)) print(p)