Apart from the index reversal argument that Daniel already mentioned in his answer, you have to keep in mind that exceptions are a much more central concept in Python compared to JavaScript.
The idea of returning some special value, in this case -1
when not finding the value, is a concept that comes from the time when exceptions were not really a well made concept in languages. Most notably, it comes from C where special return values can mean all kinds of things.
JavaScript borrows much of this, as it also has no safe way of exception handling. Since it’s a weakly typed language, it can only catch all exception types, so just catching some IndexNotFoundException
would not really work there.
In Python however, exceptions are a core concept of the language, and they are used all over the place for lots of exceptional things. So it makes sense to use them here for the case when an item is not in a list too.