searching backwards in a string

Mark Zöltsch laalien at hotmail.com
Tue Feb 12 10:27:31 EST 2002


Hi

> Short answer:  Reverse the string first.

I'm new to this python stuff and to this newsgroup too..
but why you don't use 'rfind' instead of 'find'?
I think that's much easier...

somthing like:

import string

str = 'ac ab ab ac'
res = string.rfind(str, 'ac', 0, len(str))

print 'last position :', res



SEE yA
PS sorry for bad english and grammar






More information about the Python-list mailing list