print 'Index from end of "test" in "%s" is %d' % ( string1, string1.rfind( "test" ) ) print
# find rindex of "Test" try: print 'First occurrence of "Test" from end at index', string1.rindex( "Test" ) except ValueError: print '"Test" does not occur in "%s"' % string1
print
Related Scripts with Example Source Code in same category :