Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

sum of positive numbers in array with negative python

def positive_sum(numbers):
    positive_sum = 0
    for n in numbers:
        if n > 0:
            positive_sum += n
    return positive_sum
positive_sum([1,-4,7,12])
 
PREVIOUS NEXT
Tagged: #sum #positive #numbers #array #negative #python
ADD COMMENT
Topic
Name
8+5 =