Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.34 KB | None | 0 0
  1. '''count all keyword occurences'''
  2. import keyword
  3.  
  4. def countKeyword(filename):
  5.     count = 0
  6.     f = open(filename, 'r')
  7.     for key in keyword.kwlist:
  8.         count = 0
  9.         for line in f:
  10.             if key in line:
  11.                 count = count + 1
  12.         print(key + " count: " + str(count))
  13.         f.seek(0)
  14.     return count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement