write a Python program to sum all the elements in a list.
Answers
Answered by
5
Explanation:
Given a list of numbers, write a Python program to find the sum of all the elements in the list.
Example:
Input: [12, 15, 3, 10]
Output: 40
Input: [17, 5, 3, 5]
Output: 33
Example #1:
# 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 ele in range(0, len(list1)):
total = total + list1[ele]
# printing total value
print("Sum of all elements in given list: ", total)
Output:
Sum of all elements in given list: 74
Answered by
0
Answer:
list=[1,2,3,4]
a=sum(list)
print(a)
Explanation:
list is 1+2+3+4. = 10
Similar questions
Environmental Sciences,
3 months ago
Math,
3 months ago
Chemistry,
6 months ago
English,
11 months ago