Write a function states that takes one input argument the na
Write a function states() that takes one input argument; the name of a text file. The function should print, on the screen, the number of lines, words, and characters in the file; your function should open file only once. >>>states(\'example.txt\') line count: 3 word count: 20 character count: 96
Solution
def stats(fileName): f = open(fileName) total = f.read() print(\"Line count\", total.count(\'\ \')) print(\"Word count\", len(total.split())) print(\"Character count\", len(total)) stats(\'stats.py\')