Python program to count the lines, words, and characters from a given file
kw.py
import string
data = open('/home/kodingwindow/Weekdays', 'r').read()
print("Characters - %s"%(len(data)))
print("Lines - %s"%(len(data.splitlines())))
print("Words - %s"%(len(str.split(data))))
Output
cat Weekdays 
Monday
Monday
Sunday
Wednesday
Monday
Monday
Sunday
Wednesday
Friday

kodingwindow@kw:~$ python3 kw.py
Characters - 69
Lines - 9
Words - 9
Advertisement