Sum Of an Array
Write a program to take Array of Elements and print the sum of all numbers in Array .
Input format:
- First line take an Integer input from stdin which is array length n.
- Second line take n Integers which is inputs of array .
Output format:
Print Integer which is sum of all elements in an array.
Example Input:
5
1 2 3 4 5
Output:
15
Example Input:
6
1 2 1 2 1 2
Output:
9
Solution:
n=int(input())
e=list(map(int,input().split())) # making input list changed to int type
s=0
if(n==len(e)):
for i in range(n):
s=s+e[i]
print(s)
Comments
Post a Comment