How to count empty lines in text file with Python

1 Answer

0 votes
file = open("d:\\data.txt", "r")

i = 0
for line in file:
    if line == "\n":
        i += 1

print(i)


'''
run:
 
3

'''

 



answered Nov 15, 2018 by avibootz

Related questions

1 answer 830 views
1 answer 179 views
1 answer 190 views
1 answer 155 views
155 views asked Mar 11, 2017 by avibootz
1 answer 179 views
1 answer 195 views
...