0

The user has to choose between the regular menu and the veggie menu.

However, I have difficulties calling them in the main() function. Here is what I already have:

def displayMenu():
   print ("1. regular menu\n 2. veggie menu")
   user_choice = input("Which one do you want to choose? (1 or 2)")
   return user_choice

def regularMenu(rmenu):
   rmenu =  open("regularmenu.txt","r")
   for line in rmenu:
       line.strip ()
       print(line)

def veggieMenu(vmenu):
   vmenu =  open("veggiemenu.txt","r")
   for line in vmenu:
       line.strip ()
       print(line)

def main(): # Here is where I have difficulty
   # If the user chooses 1, print regular menu
   # If the user chooses 2, print veggie menu
   # I don't know how to make the if statement here
4
  • As in the answer of the duplicate but change 'move' and 'jump' with '1' and '2'. Commented Mar 5, 2017 at 19:29
  • Your displayMenu() function returns the user choice, so why can you not operate on the return value in your main()? Commented Mar 5, 2017 at 19:30
  • @JAB Thanks. I just started learning functions. I'm not sure how to call it in main (). Commented Mar 5, 2017 at 19:34
  • @pythh The same way you called the other functions you've used in your program so far. Note that your main() will itself need to be called at some point as Python does not follow the same behavior as C/C++/Java in having a function that's called automatically at program start. Commented Mar 5, 2017 at 19:34

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.