Use .rfind():
>>> s="hello"
>>> s.rfind('l')
3
Also don’t use str as variable name or you’ll shadow the built-in str().
Use .rfind():
>>> s="hello"
>>> s.rfind('l')
3
Also don’t use str as variable name or you’ll shadow the built-in str().