Skip to content
Home » Python program to print sum of list elements

Python program to print sum of list elements

Below is the code to add the list elements

#sum of list elements
lst=list(eval(input("Enter list elements:")))
sum = 0
for i in range(len(lst)):
sum+=lst[i]
print("Sum of list elements is ",sum)

Output:

Enter list elements:1,5,8,3,7,4
[1, 5, 8, 3, 7, 4]
Sum of list elements is 28