Skip to content
Code ReadingCount the Negatives
Break the Code

Count the Negatives

Write a list for which this function gives the wrong answer.
1def count_negatives(values):
2 count = 0
3 for v in values:
4 if v <= 0:
5 count += 1
6 return count