[Tutor] last part of my programme
Peter Otten
__peter__ at web.de
Thu Sep 29 11:33:04 CEST 2011
ADRIAN KELLY wrote:
> can anyone tell me why the last part of my programme wont work. i want
> the user to have to press enter to exit but it doesn't happen through the
> python interface.
>
> the programme works fine otherwise but just shuts down when finished
(I'm assuming you are on Windows) Open a DOS window and cd to the directory
where you have stored your script. Invoke it with
python <name-of-the-script>
When you now enter the data your script is asking for you will at some point
run into the error and get a so-called "traceback" and an error message.
Here's how it looks on Linux (I've stored your script as tmp_adrian.py):
$ python tmp_adrian.py
hello
i am your computer
please enter your password: gorilla
Password Accepted
hello
please enter your firstname: peter
please enter your lastname: otten
what town are your from? won't
what county are you from? tell
Traceback (most recent call last):
File "tmp_adrian.py", line 34, in <module>
STATS()
File "tmp_adrian.py", line 26, in STATS
details=name+"\n"+town+"\n"+county
NameError: global name 'name' is not defined
$
Can you make sense of that message and find the bug that is causing it? Come
back if not.
More information about the Tutor
mailing list