Answer:
Step-by-step explanation:
The following code is written in Python. It is a function that takes in the file directory as an argument, reads the file. Then it counts the lines and words in the file and saves that count in separate variables. Then it loops through the entire file counting the characters, without counting whitespace and newlines breaks. Finally, it prints all of that information out.
def countText(file):
f = open(file, 'r')
text = f.read()
lines = len(text.split('\\'))
words = len(text.split(' '))
characters = 0
for char in text:
if (char != ' ') and (char != '\\'):
characters += 1
print("File Count:")
print("Lines: " + str(lines))
print("Words: " + str(words))
print("Characters: " + str(characters))