Python Program to find sum of array elements using for
Program
number_array = list()
total = 0
size = int(input("Enter the size of array:\t"))
print("Enter the numbers in array: ")
for i in range(int(size)):
n = input()
number_array.append(int(n))
for element in number_array:
total = total+element
print("Sum of array is:\t", total)
Output
$ python3 sum_of_array_elements_using_for.py
Enter the size of array: 4
Enter the numbers in array:
45
67
89
37
Sum of array is: 238