# recount.py import re f = file('/usr/share/dict/words', 'r') pat = re.compile(r'ear.*ness$') count = 0 for s in f: if pat.search(s): count += 1 print count