rfind bug ?

Paul Rudin paul.nospam at rudin.co.uk
Wed Apr 21 05:42:27 EDT 2010


Peter Otten <__peter__ at web.de> writes:


> OP: you may be looking for
>
>>>> a = "a bb ccc"
>>>> a[::-1].find(" ")
> 3


But you should be aware of the effeciency implications of doing
this. a[::-1] constructs a new list. It's probably faster to do e.g.:
len(a) - a.rfind(..) - 1



More information about the Python-list mailing list