Python Online Compiler
Example: Python Program to Find Sum of N Numbers using For loop
C
C++
C#
Java
Python
PHP
main.py
STDIN
Run
# 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)
6 32 455 23 33 34 23
Output
Clear
ADVERTISEMENTS