[Solved] fix thsi please [closed]


Your code has multiple errors. Try this it should work. I tried on python3 and modified for python2.7 so there could be some syntax error. I’ve explained the errors in comment

class restaurant():
  def __init__(self):
    self.name = ""
    self.menu = {}
    self.order = []
    self.bill = 0
  def print_menu(self):
    print "MENU CARD"
##This should be self.menu instead of just menu. If you use just menu it's a local variable which can't be used from other function
    self.menu = {'BBQ Grill':'50','Chicken Gollati':'80','French fries':'60',
            'Hara Bara Kabab':'90','Makani Special Dum Biriyani':'100',
             'Egg Jumbo Sandwich':'120','Roasted Prawn   Salad':'90',
              'Parathas':'80','Turkish Barbeque Plate':'100'}
#Again self.menu
    for item in self.menu:
      print item,"-",self.menu[item]
  def has_item(self):
    name = raw_input("Enter name of costumer: ")
    food = raw_input("Enter order: ")
    for i in self.menu:
      if i == food:
        print "Yes"
      else:
        print "No"

# The first parameter is always instance of the class (self).
  def takeorder(self):
    print "What would you like to order?"
    ans = "y"
    while ans == "y":
      food = raw_input("enter order - ")
# Instead of bill it should be self.bill
#Convert string value of cost to int while adding
      self.bill += int(self.menu[food])
      ans = raw_input("go on?(y/n): ")
    print self.bill
r = restaurant()
r.print_menu()
r.takeorder()

0

solved fix thsi please [closed]