How to do a very simple menu

There are often times when you want to use some form of menu. Here’s one way to do it. First, I make “ans” = True so that it will satisfy the “while” condition. Then the rest of the code is inside the “while” loop. This means that when the user presses enter, “ans” will be false / empty and the program will exit.  Everything else here should be familiar to you, but you may not have seen the use of triple quotations before. We use this in Python to allow us to do multi-line printing. Line returns are allowed so it’s great for this sort of thing and, of course, ASCII art.

Happy Coding,

antiloquax

Advertisements

Tags: ,

3 Responses to “How to do a very simple menu”

  1. francescodifusco Says:

    Reblogged this on FRANCESCO DI FUSCO.

  2. How to do a very simple menu « Team Python | FRANCESCO DI FUSCO Says:

    […] How to do a very simple menu […]

  3. Leo Says:

    source code.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: