Stop as soon as you find it
You're looking for your friend's name on a class list. The moment you spot it, you stop reading. There's no point going through the rest of the list.
A loop can do the same: the moment a box holds what you want, return its box number straight away. Returning ends the function, so the rest of the loop never runs. That also means you always get the first match.
Found it? return the box number right away.
Look for 9target = 9
5
03
19
23
38
4i
5 isn't 9. Keep going.
Move 1 of 3
Saying "it isn't here"
If the loop gets to the end without returning, nothing matched. You still have to return something, and it mustn't look like a real box number. So return −1: no box is ever numbered −1, so nobody can mistake it for an answer.
Returning 0 would be a bug. Box 0 is a real box, the very first one.
After the loop: you know nothing matched.
Not 0: box 0 is a real position.
for i in range(len(nums)):
if nums[i] == target:
return i
return -1