Finding a substring in Python

You can simply use in to find out if a string contains another string:

line = "A license for my pet fish, Eric."
if 'license' in line:
    print '"license" is in line'

Use find() to get the position of the substring:

pos = line.find('license')
if pos != -1:
    print '"license" starts at position {0} of line'.format(pos)