We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bf515d0 commit 190ffdbCopy full SHA for 190ffdb
1 file changed
tests/test_count_even.py
@@ -3,11 +3,7 @@
3
4
def count_even(arr: list[int]) -> int:
5
"""Count the number of even numbers in an array."""
6
- even = 0
7
- for num in arr:
8
- if num % 2 == 0:
9
- even += 1
10
- return even
+ return sum(1 for i in arr if i % 2 == 0)
11
12
13
# Your tests can also be benchmarks
0 commit comments