Guest User

Untitled

a guest
Oct 17th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import sys
  2. import string
  3.  
  4. file_name=sys.argv[0]
  5.  
  6. char= words = lines = theCount = aCount= 0
  7.  
  8.  
  9. with open(file_name,'r') as in_file:
  10. for line in in_file:
  11. lines +=1
  12. words +=len(line.split())
  13. char +=len(line)
  14. if 'the' in words:
  15. theCount +=1
  16. if 'a' in words:
  17. a +=1
  18. if 'an' in words:
  19. a +=1
  20.  
  21. print("Filename:", file_name)
  22. print("Number of lines:", lines)
  23. print("Number of characters:", char)
  24. print("Number of 'the'", theCount)
  25. print("Number of a/an:", aCount)
Add Comment
Please, Sign In to add comment