I want to remove empty lines, dots and commas from my textfile. I am not really sure how to do it. I tried different metods but didnt get any results
filename = "phil.txt"
def countLines():
"""
Read number of lines in the text file.
"""
numOflines = 0
with open(filename) as file:
for line in file:
numOflines += 1
print("Total number of lines is: ", numOflines)
return numOflines
countLines()
I get 19 lines but the answer should be 17 lines. I addition I want to also remove commas and dots for later use.