Thanks Kent, as far as I can see I get the same problem that on my script, i need to enter "f" 3 to 4 times before I exit the programme. Hmmm, why, I can't see it really, i thought that the fact to have the "break" command would terminate the script straight away. If I enter "f" first then the programme ends. What am i missing?

JC

John Carmona wrote:

Thanks for the help Kent, Noel and Alan. Here is my final script (it seems to be working ok but sometimes if I select "quit the programme", I need to enter that option 2 or 3 times before it works, is this a bug


Try this program. Choose option a a few times, then choose f enough times to exit. See if you can figure out what is going on.


def print_options():
      print "------------------------------"
      print "Options:"
      print "a. print options"
      print "f. quit the programme"
      print "------------------------------"
      while 1:
          choice = raw_input("Choose an option: ")
          if choice == 'a':
              print 'About to call print_options'
              print_options()
              print 'Finished calling print_options'
          if choice == 'f': break

print_options()

Kent


_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Reply via email to