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 # w  w w .j av  a 2 s.  c o  m

print(sum )

Result

Related Example