Negative in the middle
Input
find_first_negative([1, 2, -3, 4])
Output
2
The first negative number is -3 at index 2.
Full lesson preview
Search a list to find the index of the first negative number.
Problem statement
Task
Examples
Input
find_first_negative([1, 2, -3, 4])
Output
2
The first negative number is -3 at index 2.
Input format
Output format
Constraints
Samples
Input
find_first_negative([-1, 2, -3])
Output
0
The very first element is negative, so return index 0.