Lynn
0
Q:

how to add list numbers in python

# Python code to demonstrate the working of  
# sum() 
   
numbers = [1,2,3,4,5,1,4,5] 
  
# start parameter is not provided 
Sum = sum(numbers) 
print(Sum) 
  
# start = 10 
Sum = sum(numbers, 10) 
print(Sum) 
6
def sum_list(array):
    summation = 0
    for x in range(0, len(array)):
        summation += array[x]
    return summation
3
lst = []
num = int(input('How many numbers: '))
for n in range(num):
    numbers = int(input('Enter number '))
    lst.append(numbers)
print("Sum of elements in given list is :", sum(lst))
1

New to Communities?

Join the community