Program 5: Write an iterative code to find the sum of all elements of a list

Clear Doubts with Computer Tutor
In case you’re facing problems in understanding concepts, writing programs, solving questions, want to learn fun facts | tips | tricks or absolutely anything around computer science, feel free to join CTs learner-teacher community: students.computertutor.in

# Python program to find sum of elements in list
total = 0

# creating a list
list1 = [11, 5, 17, 18, 23]

# Iterate each element in list
# and add them in variale total
for element in range(0, len(list1)):
   total = total + list1[element]

# printing total value
print("Sum of all elements in given list: ", total)

You cannot copy content of this page