python sum of array code example
Example 1: addition of array in python with input
#Python program to add all the array elements using the built-in function
lst = []
num = int(input("Enter the size of the array: "))
print("Enter array elements: ")
for n in range(num):
numbers = int(input())
lst.append(numbers)
print("Sum:", sum(lst))
Example 2: python sum of list
>>> list = [1, 2, 3]
>>> sum(list)
6