searching from end of string : rindex « String « Python Tutorial






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








5.26.rindex
5.26.1.index from right
5.26.2.rindex with index
5.26.3.searching from end of string