Finding Peoples' Names in Files

Tim Williams tdwdotnet at gmail.com
Thu Oct 11 17:34:01 CEST 2007


On 11/10/2007, brad <byte8bits at gmail.com> wrote:
> Crazy question, but has anyone attempted this or seen Python code that
> does? For example, if a text file contained 'Guido' and or 'Robert' and
> or 'Susan', then we should return True, otherwise return False.
> --
> http://mail.python.org/mailman/listinfo/python-list
>


Text = open(fname).read()

def a_function():
    for Name in ['Guido', Robert',Susan']:
       if Name in Text:
           return 1

if a_function():
    print "A name was found"

:)



More information about the Python-list mailing list