From Bistre Plover, 1 Week ago, written in Plain Text.
Embed
  1. import re
  2. inp = open('input.txt')
  3. out = open('output.txt','w')
  4. lines = 0
  5. words = 0
  6. letters = 0
  7. flag = 0
  8. for line in inp:
  9.     lines += 1
  10.     words += len(re.findall(r'[^_, ,\W]+',line)) - len(re.findall(r'\s?[0-9]+[^A-z]\s?',line))
  11.     letters += len(re.findall(r'[qwertyuioplkjhgfdsazxcvbnmQWERTYUIOPLKJHGFDSAZXCVBNM]',line))
  12. print("Input file contains:")
  13. print(letters,"letters")
  14. print(words,"words")
  15. print(lines,"lines")
  16. inp.close()
  17. out.close()