Mega Code Archive

 
Categories / Python Tutorial / String
 

The find method finds a substring within a larger string

# It returns the leftmost index  where the substring is found.  If it is not found, â€“1 is returned:  print 'With a moo-moo here, and a moo-moo there'.find('moo') title = "A B C D" print title.find('A') print title.find('B') print title.find('D') print title.find('E')