Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

sum of array in python

def sumOfArr(a):
    sum=0
    for i in a:
        sum += i
    return sum
a = [1,2,3,4]
res=sumOfArr(a)
print(res) # output = 10
 
PREVIOUS NEXT
Tagged: #sum #array #python
ADD COMMENT
Topic
Name
1+2 =