[Tutor] The very first program in python

Mark Lawrence breamoreboy at yahoo.co.uk
Thu Nov 12 12:42:36 EST 2015


On 12/11/2015 17:16, Sajjadul Islam wrote:
> Hello
>
> I have coded the first snippet in python  - defined a function , then I am
> getting error if I try call the function from the IDLE window. The error is
> :
>
> Traceback (most recent call last):
>    File "<stdin>", line 1, in <module>
> NameError: name 'print_lol' is not defined
>
> print_lol is the name of the function that is declared and defined inside
> the file called nester.py and IDLE is called in the same path. What is that
> I am missing here ?
>
> Thanks
>

You need to either:-

import nester
nester.print_lol()

or:-

from nester import print_lol
print_lol()

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence



More information about the Tutor mailing list