Python Program to Find Sum of N Numbers using For loop
ADVERTISEMENTS
Python program to find sum of N numbers using for loop. In this article, You will learn how to find the sum of N numbers in python using for loop.
Source Code
# Python Program to Find Sum of N Numbers using For loop
x, s, sum = [], 0, 0
# s - To store the size of the array
# x - To store the array element to store the input numbers
print ("----Enter the size of the array----")
s = int (input ())
print ("\n\n----The sum of the ", s, " input numbers----\n")
for i in range (s):
x.append (int (input ()))
sum += x[i]
print ("\n\nThe total sum is: ", sum)
Output
----Enter the size of the array----
6
----The sum of the 6 input numbers----
32
455
23
33
34
23
The total sum is: 600