Add the Positives

Sometimes you need to keep only the useful values from a list and ignore the negative ones. Write positive_sum, which takes a list of numbers arr and returns the sum of only the positive elements. If there are no positive numbers, return 0.

Примеры

Ввод
[1, 2, 3, 4, 5]
Вывод
15
Ввод
[1, -2, 3, 4, 5]
Вывод
13
Ввод
[-1, -2, -3, -4, -5]
Вывод
0

Нужно реализовать

def positive_sum(arr: list[int]) -> int:

Теги

listsarraymath
PostgreSQLv16

Tady se objeví výsledek běhu kódu

Visible tests
1
Input
[1,2,3,4,5]
Expected15
2
Input
[1,-2,3,4,5]
Expected13
3
Input
[-1,-2,-3,-4,-5]
Expected0
4
Input
[]
Expected0
5
Input
[1,-2,3,4,-5]
Expected8
6
Input
[-5,-2,1,3,4]
Expected8
Focus radio
Paused · SomaFM · Fluid