[Tutor] College student having python problems

Alan Gauld alan.gauld at btinternet.com
Fri Dec 14 20:11:58 CET 2012


On 06/12/12 23:43, Mark Rourke wrote:

> def showMenu():
> #THIS IS ALL PART OF SHOWMENU:
>          #keep getting items for this order until the user wants to end the order
>                       #set initial quantities of items
>      numBurgers=20;
>      numFries=20;
>      numSodas=20;
>      menuItem = showMenu()<---------ERROR THERE<----
>                  #ordering stuff from the menu

> def main():
>      getOrderNumber()
>      showMenu()
> main()

main calls showMenu which calls showMenu which calls showMenu etc....

You need to break the cycle of showMenu calls. Thats usually done by 
inserting some kind of check before the call to showMenu inside showMenu 
  so that you only call it when needed.

However I suspect what you really need here is to use a loop instead of 
having showMenu calling itself.

choice = None
while not choice     # or some other test condition here
    choice = showMenu()

HTH
-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/



More information about the Tutor mailing list