You get an array of numbers, return the sum of all of the positives ones.

Example `[1,-4,7,12]` => `1 + 7 + 12 = 20`

Note: if there is nothing to sum, the sum is default to `0`.

Difficulty: introductory

Starter code:

def positive_sum(arr):
	

Solutions:
def positive_sum(arr):
    return sum(x for x in arr if x > 0)


def positive_sum(arr):
    sum = 0
    for e in arr:
        if e > 0:
            sum = sum + e
    return sum

def positive_sum(arr):
    return sum(filter(lambda x: x > 0,arr))

def positive_sum(arr):
    ''' I really hate these one line codes, but here I am...
        trying to be cool here... and writing some'''
    return sum([x if x > 0 else 0 for x in arr])


positive_sum = lambda l: sum(x for x in l if x>=0)


def positive_sum(arr):
    return sum(i for i in arr if i > 0)


def positive_sum(list):
    answer = 0
    for numbers in list: 
        if numbers > 0:
            answer += numbers
    return answer

def positive_sum(arr):
    summ = 0
    for temp in arr :
        if temp > 0 :
            summ += temp
    return summ


def positive_sum(arr):
    return sum( max(i, 0) for i in arr )

positive_sum = lambda a: sum(e for e in a if e > 0)

def positive_sum(arr):
    return sum([i for i in arr if i==abs(i)])

def positive_sum(arr):
    L = []
    for i in arr:
        if (i > 0):
            L.append(i)
    return (sum(L))
      
      
      


def positive_sum(arr):
    # Your code here
    return sum([x for x in arr if x > 0])


positive_sum=lambda a:sum(x>0and x for x in a)

def positive_sum(arr):
    nums = [num for num in arr if num > 0]
    return sum(nums)

positive_sum=lambda arr:sum(e for e in arr if e>0)

def positive_sum(arr):
    add = 0
    addtemp = 0
    index = 0
    for i in arr:
        if i > 0:
            add = arr[index]
            index += 1
            add = add + addtemp
            addtemp = add
            print(add)
        else:
            print("skipping the {}".format(i))
            index += 1
    if add > 0:
        return(add)
    else:
        return(0)

def positive_sum(arr):
    summ = 0
    for num in arr:
        if num >= 0:
            summ += num
    return summ


def positive_sum(arr):
    add =[]
    for item in arr:
        if item > 0:
            add.append(item)
    return sum(add)
    return 0


def positive_sum(arr):
    res = 0
    for i in arr:
        if not arr:
            return 0
        elif i < 0:
            continue
        else:
            res += i
    return res


''' Suma únicamente los valores positivos, los negativos se los salta.
    En caso de que la lista esté vacía, devuelve 0
'''
def positive_sum(arr):
    sum = 0
    if not arr:
        return sum
    for n in arr:
        if(n>=0):
            sum = sum + n
    return sum



def positive_sum(n):
    b = 0
    if not n:
        return 0
    else:
        for i in range(len(n)):
            if n[i] < 0:
                pass
            else:
                b += n[i]
        return b


from functools import reduce
def positive_sum(arr):
    return reduce((lambda acc,n: acc+n if n>0 else acc), arr, 0)


def positive_sum(arr):
    sum = 0
    for n in range(0,len(arr)):
        if arr[n] > 0: sum += arr[n]
    return sum


def positive_sum(arr):
    positive_list = []
    for num in arr:
        if num >= 0:
            positive_list.append(num)
    result = sum(positive_list)
    return result


def positive_sum(arr):
    sum = 0
    if arr:
        for numb in arr:
            if (numb > 0):
                sum = sum + numb
    return sum


def positive_sum(arr):
    return sum([a for a in arr if a > 0])


def positive_sum(arr):
    return sum([abs(x) for x in arr] + arr) // 2

positive_sum = lambda a: sum(filter(lambda x: x > 0, a))

positive_sum=lambda a:sum(map(lambda n:n>0 and n,a))

positive_sum = lambda lst: sum(list(filter(lambda _: _ > 0, lst)))

from functools import reduce
def positive_sum(arr):
    arr = list(filter((lambda x: x > 0), arr))
    try:
        return reduce((lambda x,y: x+y), arr)
    except:
        return 0


def positive_sum(arr):
    return sum([_ for _ in arr if _ > 0])

from functools import reduce
def positive_sum(arr):
    return reduce(lambda x,y: x+max(0,y), arr, 0)

def positive_sum(arr):
    sum = 0
    for el in arr:
        if el > 0:
            sum += int(el)
    return sum


def positive_sum(arr):#function declaration
    sum=0             #instiallization of zero
    for i in arr:     # for loop to check the integers in the array
        if i>0:       # condiation
            sum=sum+i #This condiation will add all the numbers>0
    return sum        #will give sum of all the positive integres


def positive_sum(arr):
    total = 0
    for a in arr:
        if "-" not in str(a):
            total += a
  
    return total


def positive_sum(arr):
  res = []
  for x in arr:
      if x > 0:
        res.append(x)
  return sum(res)


def positive_sum(arr):
    ans = []
    for n in list(arr):
        if n >= int(0):
           ans.append(n)
    return sum(ans)


def positive_sum(arr):
    # Your code here
    pos_arr = list([x for x in arr if x>0])
    if pos_arr:
        return sum(pos_arr)
    return 0