programming-examples/python/Input_Output/Python program to count the number of lines in a text file.py

6 lines
226 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
def file_lengthy(fname):
with open(fname) as f:
for i, l in enumerate(f):
pass
return i + 1
print("Number of lines in the file: ",file_lengthy("test.txt"))