Page 80 -
P. 80

idle error





                             You were to write a small program that imports your newly created module, defines a small list
                             called “cast,” and then uses the function provided by your module to display the contents of the
                             list on screen. You were to use the following list data (all strings): Palin, Cleese, Idle, Jones,
                             Gilliam, and Chapman.


                                         import nester
             It’s a simple three-
             line program. There’s
             nothing too difficult       cast = ['Palin’, 'Cleese’, 'Idle’, 'Jones’, 'Gilliam’, 'Chapman’]
             here.
                                         print_lol(cast)


                             Open your program in IDLE’s edit window, and then press F5 to execute your code. Describe
                             what happens in the space below:

               But it didn’t work!       IDLE gives an error, and the program does not run!








              With your program in the IDLE edit window, pressing F5 (or choosing Run Module from the Run menu) does
              indeed cause problems:













              Your program does not appear to have executed and an error message is reported:

              >>> ================================ RESTART ================================
              >>>
              Traceback (most recent call last):
                File "/Users/barryp/HeadFirstPython/chapter2/try_nester.py", line 4, in <module>
                  print_lol(cast)
              NameError: name 'print_lol' is not defined
                                                              With your program in IDLE, pressing F5 causes
              >>>                                            a NameError…it looks like your function can’t be
                                                             found!!!


           44    Chapter 2
   75   76   77   78   79   80   81   82   83   84   85