[Tutor] help
Chris Smith
smichr at bigfoot.com
Wed May 11 23:11:41 CEST 2005
On Wednesday, May 11, 2005, at 08:09 America/Chicago,
tutor-request at python.org wrote:
> hi
> i'm trying to extend a list program by adding a test, problem is after
> getting the menu of taking the test i can't seem to get the test
> running
> i.e viewing of questions and answers. here's what i tried to do
> menu_item = 0
> list = []
> while menu_item !=9:
> print "---------------------"
> print "1. print the questions"
> print "2. take the test"
> print "3. quit"
> menu_item = input("pick an item from the menu: ")
>
Hi Feziwe,
If you are trying to modify someone else's code, then the work that you
would have done to write it now has to go into trying to understand
what they have already done. Not to lecture too much, but if you didn't
write it then work through it piece by piece to see how it works. What
you will notice that relates to your problem is that there is a 'while'
loop that requires a menu_item to be not equal to 9. Since your menu
never asks the user to enter a 9, you will never get out of that loop.
Also, check to see what *does* happen when a 2 is pressed: if there is
not an instruction to call a function, then the instructions in that
part of the 'if...elif...else' section will be done and the 'while'
loop will resume (since menu_item was not 9.
Does this get you started toward understanding the problem?
/c
More information about the Tutor
mailing list