Which fix removes the bug?
def count_evens(nums):
c = 0
for n in nums:
if n % 2 == 1:
c += 1
return c
- Change
c += 1toc += n - Change
% 2to% 3 - Start
cat 1 - Change
== 1to== 0
Even numbers have remainder 0, so compare against 0.
Play Problem Solving ▸