Python program to find sum of elements in list

sum of elements

creating an empty list ### “'”

list = []

number of elements as input

n = int(input("Enter number of elements : "))

iterating till the range

for i in range(0, n):
elem = int(input())

list.append(elem) # adding the element

#print(list)

sum of elements “”"

def sumlist(list):
sum=0
for i in range(len(list)):
sum = sum+list[i]
return sum

print(list)
print("sum of list: ",sumlist(list))

3 Likes

@ashutoshbrezzasingh

Nice keep it up.

Very nice @ashutoshbrezzasingh , Keep it up.
Keep learning keep growing.