str.find() always returns -1 if not found.
Can I write an expression instead of str.find() and return None if not found?
str.find() always returns -1 if not found. Can I write an expression instead of
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If I sum up, you want something which:
Nonewhen not foundThe only solution I could come up with which satisfies all requirements is this weird thing:
For example:
I don’t have a Python 2.4 install to test one, so I can only hope it works.