w3resource logo


Python Exercises

Python: Write a Python program to sum all the items in a list


Write a Python program to sum all the items in a list.

Sample Solution :

Python Code :

def sum_list(items):
    sum_numbers = 0
    for x in items:
        sum_numbers += x
    return sum_numbers
print(sum_list([1,2,-8]))

Console :

Copy and paste the above code and press "Enter key" to execute :

Post your code through Disqus