Review the AI
Positive Sum
Label each solution: correct, correct but needlessly slow, or buggy. The buggy one is off by a single character.Problem
positive_sum(values): return the sum of the positive numbers in the list.Solution A
1def positive_sum(values):
2 return sum(v for v in values if v > 0)
Solution B
1def positive_sum(values):
2 total = 0
3 for v in values:
4 if v > 0:
5 total =+ v
6 return total
Solution C
1def positive_sum(values):
2 total = 0
3 for v in sorted(values):
4 if v > 0:
5 total += v
6 return total