Do I have to cause an ValueError in Python
exception, list, python
Solution
Note that the latter approach is going against the generally accepted "pythonic" philosophy of EAFP, or "It is Easier to Ask for Forgiveness than Permission.", while the former follows it.
Problem
I have this code: ``` chars = #some list try: indx = chars.index(chars) except ValueError: #doSomething else: #doSomethingElse ``` I want to be able to do this because I don't like knowfully causing Exceptions: ``` chars = #some list indx = chars.index(chars) if indx == -1: #doSomething else: #doSomethingElse ``` Is there a way I can do this?