Login
Remember
Register
Ask a Question
Write a Python program to count the total number of lines in a text file?
0
votes
asked
May 12, 2023
in
Python Flask
by
SakshiSharma
Write a Python program to count the total number of lines in a text file?
python-count-method
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
May 12, 2023
by
SakshiSharma
def file_count(fname):
with open(fname) as f:
for i, 1 in enumerate(f):
paas
return i+1
print(“Total number of lines in the text file: ”, file_count(“file.txt”))
...