''' This code use for find one string in another string return the index from where string is found, otherwise return -1 ''' data="Life is very easy is with Python" print data.find("is") print data.rfind("is") ''' find in a range(startIndex,endIndex) ''' print data.find("is",0,5) print data.find("is",0,10) ''' find from last ''' print data.rfind("is",0,10) print data.rfind("is",0,5)
Output:
5 18 -1 5 5 -1
0 comments:
Post a Comment