← back to unit
Easy
# searching easy
The First Negative Reading
The weather robot logs the temperature every hour, and you need to know when it first dipped below zero. 🥶
You get a list of nums. Print the first negative number, or none if the day stayed warm.
Example:
Input: nums = [3, 1, -2, 5, -8]
Output: -2
3 and 1 aren't negative, but -2 is — that's the first number below zero, so we print it and stop.
💡 need a hint?
srch-first-negative.py🔒 given lines are locked — write your code in between
loading...