Replace for Goto

Adonis adonisv at earthlink.net
Wed May 28 21:13:20 EDT 2003


"Dvm5" <dvm5_0 at hotmail.com> wrote in message
news:aa2e3602.0305281646.32cf1129 at posting.google.com...
> I'm used to Basic. There is a Goto/Label command, you put goto where
> you want it to come from and label where you want it to go. Simple.
> How can I do this in Python?
>
> What I'm trying to do is create a "play again" type user interface.
> Thus, I can't alter the program to use an If command; the option has
> to be at the end, and the effect has to be at the begining! How do I
> accomplish this?
>
> If there is another way, other than a similar thing to Goto, tell me
> that, as well as a similar thing for goto. It would probably be useful
> later on...
>
> Thanks for all help ^_^

What about:

>>> while 1:
...     print '''Menu
...                A) Play Game
...                B) View Scores
...                C) Quit
...
...             '''
...     x = raw_input('Enter Option: ')
...     if x.lower() == 'c':
...             break

This will loop until C is pressed.

Hope this helps.

Adonis






More information about the Python-list mailing list