New to Python.

Sean Ross sross at connectmail.carleton.ca
Thu Mar 18 00:10:52 EST 2004


"Sean Ross" <sross at connectmail.carleton.ca> wrote in message
news:m3a6c.19554$E71.1405188 at news20.bellglobal.com...
[snip]
> # otherwise, you can go line by line
> source = file('C:\Python23\Samples\Bob.txt')
> tally = 0
> for line in source:
>     if "customer" in line:
>         tally += 1
> source.close()
>
[snip]

# sorry, that should be
source = file('C:\Python23\Samples\Bob.txt')
tally = 0
for line in source:
         tally += line.count("customer")
source.close()







More information about the Python-list mailing list