[Tutor] name 'x" is not defined
Kent Johnson
kent37 at tds.net
Fri Oct 17 13:31:57 CEST 2008
On Fri, Oct 17, 2008 at 4:59 AM, carme colominas
<carme.colominas at gmail.com> wrote:
> can someone explain
> me, what does it mean that a function is not defined and how to proceed?
>
> For example, for fdist:
>
>>> for word in nltk.corpus.brown.words():
> if fdist(word)>= 3:
> print(word)
>
> I get the following:
>
> Traceback (most recent call last):
> File "<pyshell#47>", line 2, in <module>
> if fdist(word)>= 3:
> NameError: name 'fdist' is not defined
It means that Python doesn't know what fdist means. You have to tell
it, either by defining an fdist() function yourself (using def) or by
importing a module that includes it.
Kent
More information about the Tutor
mailing list