Search in textfiles?

Simon Brunning SBrunning at
Mon May 14 05:36:35 EDT 2001

> import string
> word = raw_input("Write a word ")
> c=open('10 Maj 08_580,2183,106_nyheter_1022,00.html.txt', 'r')
> textstring =
> index = string.find(textstring, word)
> if index > 0:
>     print "yes the word exists in the textfile"
> else:
>     print "it doesn´t exist"
> this code I rote, but what can be done if big letters should not be
> threated
> different than small letters?
Replace the 4th line with:

index = string.find(string.upper(textstring), string.upper(word))

Simon Brunning
TriSystems Ltd.
sbrunning at

The information in this email is confidential and may be legally privileged.
It is intended solely for the addressee. Access to this email by anyone else
is unauthorised. If you are not the intended recipient, any disclosure,
copying, distribution, or any action taken or omitted to be taken in
reliance on it, is prohibited and may be unlawful. TriSystems Ltd. cannot
accept liability for statements made which are clearly the senders own.

More information about the Python-list mailing list