Python - Compute the sum of all the items in a list

Description

Compute the sum of all the items in a list

Demo

sum = 0 
for x in [1, 2, 3, 4]: 
    sum = sum + x # from w  w w  . ja  v  a  2  s.co m

print(sum )

Result

Related Example