Result is not Displayed

Irmen de Jong irmen.NOSPAM at xs4all.nl
Tue Nov 22 03:52:51 EST 2016


On 22-11-2016 9:18, prihantoro2001 at gmail.com wrote:
> Dear all, 
> 
> i am new to Python and have this problem
> 
> =====
> import nltk
> puzzle_letters = nltk.FreqDist('egivrvonl')
> obligatory = 'r'
> wordlist = nltk.corpus.words.words()
> [w for w in wordlist if len(w) >= 6
> and obligatory in w
> and nltk.FreqDist(w) <= puzzle_letters]
> print puzzle_letters
> ======
> 
> this gives me <FreqDist with 8 samples and 9 outcomes>
> while the expected outcome is ['glover', 'govern', ...]
> did i miss something?


Review your code carefully. You're printing the wrong thing at the end, and you're doing
nothing with the list comprehension that comes before it.

-irmen




More information about the Python-list mailing list