"Ron Stephens" <rdsteph at earthlink.net> wrote ... > Steve offered me this good code: > > choice = raw_input("Option: ") > if choice == 1: > # code for case 1 > elif choice == 2: > # code for case 2 > elif choice == 3: > : > : > else: > print "Invalid choice" > > Steve, thanks. I guess in this case, when the code for a choice finishes > executing, program flow would go to (Alex: sorry about that particular choice of > words;-))) the end, or right after the print "invalid choice " statement...? > After the particular case selected has executed control "drops off the bottom" to whatever follows. Of course you are at liberty to include in it a loop. By the way, those integers I used should really be strings. So you could do something like: while 1: # loop forever choice = raw_input("Operation:") if choice == "this": # or maybe "1" # do this elif choice == "that": # or maybe "2", etc... # do that elif ... : elif choice == "quit": break # exit from infinite loop else: print "Invalid operation" This will loop, peforming the selected operations, until the user enters "quit", or some exception terminates the run. regards Steve
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4