words = [line.strip() for line in open('/usr/share/dict/words') if line.strip()] print(sum(1 for w in words if not w.isalpha())) # count number of matches