Menus and Choices

Creating a menu that you can use with a program any time you like is quite a useful thing to do. 

This code simply shows a menu and handles the choices from that menu. 

The definition called displayMenu(): simply shows the menu - nothing else. 

The definition called getMenuChoice(): just gets the user input and returns it - nothing else. 

The definition handleMenuChoice(choice):  Takes the choice (converted to an integer) and then checks what that choice is using IF statements

There are two places where the menu choice number is printed out - this is not needed really but it shows that the choice is getting through to the sub routine correctly. (These extra bits of code are sometimes useful when de bugging a code) 

Splitting your code up 

Instead of printing out the message in the handleMenuChoice(choice) definition we could add one called cheese....  I replaced the print statement (commented it out) with a call to the definition cheese():