New to Python.

droog droog at orange.gov
Wed Mar 17 22:07:05 EST 2004


I was looking for the simpliest way of doing it. This is what I tried
to do. 

f = open('C:\Python23\Samples\Bob.txt', 'r')
counter = 0
while True:
	line = f.readline()
	if len(line) == 0:
		break
	if line.find('customer'):
		counter = counter + 1
		print 'Found it ' + str(counter)

 

On Thu, 18 Mar 2004 02:53:48 GMT, droog <droog at orange.gov> wrote:

>
>Hello!
>
>I have just started learning python and encountered a problem.
>All I wanted to do, was to open a text file search and count the
>number of occurances of a single word and print that count.
>Thanks for help.




More information about the Python-list mailing list