Count the positives
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
This one builds on a lesson you haven't finished yet. Do that lesson first:
Python Basics · Functions →
Count the positives
Return how many numbers in a list are greater than 0. Zero itself does not count.
A counter starts at 0 and grows by 1 each time the condition is true.
Difficulty 2/5 · 140 coins + a small bonus on first completion today
Write count_positive(nums) that returns how many numbers in the list are greater than 0.
Click Run to see the output here.