Home
Recent Q&A
Java
Cloud
JavaScript
Python
SQL
PHP
HTML
C++
Data Science
DBMS
Devops
Hadoop
Machine Learning
Azure
Blockchain
Devops
Ask a Question
Write a Python program to count the total number of lines in a text file?
Home
Python Flask
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”))
Related questions
0
votes
Q: Can you write an efficient code to count the number of capital letters in a file?
asked
May 12, 2023
in
Python Flask
by
SakshiSharma
python-code
0
votes
Q: Write a program to count the number of capital letters in a file?
asked
May 17, 2020
in
Python
by
sharadyadav1986
#python-program-counter
Python-questions-answers
0
votes
Q: Write a Java program to count the number of words present in a string?
asked
May 4, 2021
in
JAVA
by
SakshiSharma
#java-program
java
Java-questions-answers
0
votes
Q: Count the number of words in text collection, text6, ending with ship?
asked
Oct 22, 2020
in
NLP using Python
by
rahuljain1
#text-collection
0
votes
Q: Count the number of words in text collection, text6, which have only digits as characters?
asked
Oct 22, 2020
in
NLP using Python
by
rahuljain1
#nlp-text
#nlp-text-collection
0
votes
Q: What is the total number of unique words present in text collection, text6, while Considering characters too as words
asked
Oct 22, 2020
in
NLP using Python
by
rahuljain1
#text-collection
+1
vote
Q: Write a python program to check if the number given is a palindrome or not
asked
Feb 15, 2021
in
Python
by
SakshiSharma
#python-program
palindrome-program
python-palindrome
Python-questions-answers
+1
vote
Q: Write a python program to print the factorial of a number.
asked
Feb 15, 2021
in
Python
by
SakshiSharma
#python-factorial-number
factorial-number-function
factorial-program
python-program
Python-questions-answers
0
votes
Q: How to Determining Total Word Count in NLTK
asked
Oct 22, 2020
in
NLP using Python
by
rahuljain1
#nltk-word-count
#total-word-count
+1
vote
Q: Generally speaking, how does the file size change if the total number of pixels of an image is doubled?
asked
Dec 27, 2022
in
Digital Primer
by
john ganales
digital-primer
...