Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import string
- F = open('input.txt', 'r')
- words = 0
- letters = 0
- text = F.readlines()
- lines = len(text)
- for line in text:
- w = ''
- for s in line.strip()+' ':
- if s in string.ascii_letters:
- letters += 1
- w += s
- if s in " '-.,!?" and w:
- words += 1
- #print(w)
- w = ''
- print("""Input file contains:
- """+str(letters)+""" letters
- """+str(words)+""" words
- """+str(lines)+""" lines""")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement