Skip to content

Loops · warm-up

The first negative

Write first_negative(nums) returning the first number below zero, or None if there is none. Stop looking as soon as you find it.

Run adds print(first_negative([3, -1, -5])) after your code, to try it.

Stuck on the idea rather than the code? The Stopping early, and loops in loops lesson walks through it.