Caricamento dell'esercizio…
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]0def positive_sum(arr: list[int]) -> int:
Accedi per vedere la cronologia degli invii
AccediAccedi per usare l'AI Mentor
Accedi[1,2,3,4,5]15[1,-2,3,4,5]13[-1,-2,-3,-4,-5]0[]0[1,-2,3,4,-5]8[-5,-2,1,3,4]8