Compute the sum of all the items in a list
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 )