string1 = "Test1, test2, test3, test4, Test5, test6"
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
|