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 938 views
1 answer 295 views
1 answer 293 views
1 answer 249 views
249 views asked Mar 11, 2017 by avibootz
1 answer 275 views
1 answer 294 views
...