Using python to count lines in a file

python

#1

Hello,
I am trying to use python to count the lines in a file. I have the following code.

fhand = open('test.txt')
count = 0 
for line in fhand:
    count = count + 1 

print 'Line Count'.count

However, when I run the file. I get the following response. What am I doing incorrectly?

<built-in method count of str object at 0x7fe53e4a7750>


#2

Try this:

print 'Line Count: ', count

or:

print 'Line Count: %s' % count


#3

Thank you. The latter option worked!