在Python中调用函数

时间:2017-03-05 19:27:47

标签: python function python-3.x

用户必须在常规菜单和素食菜单之间进行选择。

但是,我在main()函数中调用它们有困难。这是我已经拥有的:

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

0 个答案:

没有答案