searching from end of string : Rindex : String PYTHON TUTORIALS


PYTHON TUTORIALS » String » Rindex »

 

searching from end of string


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



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo String
» Rindex