SyntaxFix
Write A Post
Hire A Developer
Questions
There is nothing wrong with your code that uses ValueError. Here's yet another one-liner if you'd like to avoid exceptions:
ValueError
thing_index = next((i for i, x in enumerate(thing_list) if x == thing), -1)