Basta Fazoolin

Project link:
https://www.codecademy.com/courses/learn-python-3/projects/basta-fazoolin

I am having a syntax error, but I don’t know what I’m doing wrong.

here is my code:

class Menu:
def init(self, name, items, start_time,end_time):
self.name = name
self.items = items
self.start_time =start_time
self.end_time = end_time

def repr(self):
print("{name} menu available from {start_time} to {end_time}".format(name=self.name, start_time=str(self.start_time), end_time= str(self.end_time))

brunch_list = { “pancakes”: 7.50, “waffles”: 9.00, “burger”: 11.00, “home fries”: 4.50, “coffee”: 1.50, “espresso”: 3.00, “tea”: 1.00, “mimosa”: 10.50, “orange juice”: 3.50 }

early_bird_list = {‘salumeria plate’: 8.00, ‘salad and breadsticks (serves 2, no refills)’: 14.00, ‘pizza with quattro formaggi’: 9.00, ‘duck ragu’: 17.50, ‘mushroom ravioli (vegan)’: 13.50, ‘coffee’: 1.50, ‘espresso’: 3.00}

dinner_list = {‘crostini with eggplant caponata’: 13.00, ‘ceaser salad’: 16.00, ‘pizza with quattro formaggi’: 11.00, ‘duck ragu’: 19.50, ‘mushroom ravioli (vegan)’: 13.50, ‘coffee’: 2.00, ‘espresso’: 3.00}

kids_list = {‘chicken nuggets’: 6.50, ‘fusilli with wild mushrooms’: 12.00, ‘apple juice’: 3.00 }

brunch = Menu(‘brunch’, brunch_list , 11, 16)

early_bird = Menu(“early_bird”, early_bird_list , 1500, 1800)

dinner = Menu(“dinner”, dinner_list , 1700, 2300)

kids = Menu(“kids”, kids_list , 1100, 2100)

print(brunch)

And here is the error message:

File “script.py”, line 12
brunch_list = { “pancakes”: 7.50, “waffles”: 9.00, “burger”: 11.00, “home fries”: 4.50, “coffee”: 1.50, “espresso”: 3.00, “tea”: 1.00, “mimosa”: 10.50, “orange juice”: 3.50 }
^
SyntaxError: invalid syntax

Hello, @datablaster42447, and welcome to the forums. It would help a great deal if you would format your code in your post. You can do that by putting three back ticks sometimes referred to as back quotes on a line by themselves both above and below your code. Highlighting your code, and then clicking the </> button (preformatted text button) will do this for you, or you can type the back ticks in yourself.

```
code goes here
```

As far as your error is concerned though, frequently when we have a syntax error on a line of code that looks correct, the problem is on the line before it. Usually there is something missing like a closing brace or parenthesis.

2 Likes

Thanks,

class Menu:
  def **init** (self, name, items, start_time,end_time):
    self.name = name
    self.items = items
    self.start_time =start_time
    self.end_time = end_time

  def **repr** (self):
     print("{name} menu available from {start_time} to {end_time}".format(name=self.name, start_time=str(self.start_time), end_time= str(self.end_time))


brunch_list = { “pancakes”: 7.50, “waffles”: 9.00, “burger”: 11.00, “home fries”: 4.50, “coffee”: 1.50, “espresso”: 3.00, “tea”: 1.00, “mimosa”: 10.50, “orange juice”: 3.50 }

early_bird_list = {‘salumeria plate’: 8.00, ‘salad and breadsticks (serves 2, no refills)’: 14.00, ‘pizza with quattro formaggi’: 9.00, ‘duck ragu’: 17.50, ‘mushroom ravioli (vegan)’: 13.50, ‘coffee’: 1.50, ‘espresso’: 3.00}

dinner_list = {‘crostini with eggplant caponata’: 13.00, ‘ceaser salad’: 16.00, ‘pizza with quattro formaggi’: 11.00, ‘duck ragu’: 19.50, ‘mushroom ravioli (vegan)’: 13.50, ‘coffee’: 2.00, ‘espresso’: 3.00}

kids_list = {‘chicken nuggets’: 6.50, ‘fusilli with wild mushrooms’: 12.00, ‘apple juice’: 3.00 }



brunch = Menu(‘brunch’, brunch_list , 11, 16)

early_bird = Menu(“early_bird”, early_bird_list , 1500, 1800)

dinner = Menu(“dinner”, dinner_list , 1700, 2300)

kids = Menu(“kids”, kids_list , 1100, 2100)

print(brunch)
1 Like

It looks like you copied the code from your post. The underscores were changed to asterisks, and the quotation marks are non-standard. The forum’s markdown does that. That’s why we need to use the back ticks to preserve our code. If you re-copy your original code from the Learning Environment, and paste it between the sets of back ticks, it will appear correctly.

Okay, thanks.

class Menu:
  def __init__(self, name, items, start_time,end_time):
    self.name = name
    self.items = items
    self.start_time =start_time
    self.end_time = end_time


  def __repr__(self):
    print("{name} menu available from {start_time} to {end_time}".format(name=self.name, start_time=str(self.start_time), end_time= str(self.end_time))
    
brunch_list = { "pancakes": 7.50, "waffles": 9.00, "burger": 11.00, "home fries": 4.50, "coffee": 1.50, "espresso": 3.00, "tea": 1.00, "mimosa": 10.50, "orange juice": 3.50 }

early_bird_list = {'salumeria plate': 8.00, 'salad and breadsticks (serves 2, no refills)': 14.00, 'pizza with quattro formaggi': 9.00, 'duck ragu': 17.50, 'mushroom ravioli (vegan)': 13.50, 'coffee': 1.50, 'espresso': 3.00}


dinner_list = {'crostini with eggplant caponata': 13.00, 'ceaser salad': 16.00, 'pizza with quattro formaggi': 11.00, 'duck ragu': 19.50, 'mushroom ravioli (vegan)': 13.50, 'coffee': 2.00, 'espresso': 3.00}

kids_list = {'chicken nuggets': 6.50, 'fusilli with wild mushrooms': 12.00, 'apple juice': 3.00 }

brunch = Menu('brunch', brunch_list , 11, 16)

early_bird = Menu("early_bird", early_bird_list , 1500, 1800)

dinner = Menu("dinner", dinner_list , 1700, 2300)


kids = Menu("kids", kids_list , 1100, 2100)

print(brunch)

2 Likes

Much better! :smiley:
Have you checked the line above the line referenced by the error message?

Yes, I spent almost two hours examining the code

Count the ( )'s. You have one more ('s than you do )'s. :wink:

Hint
print("{name} menu available from {start_time} to {end_time}".format(name=self.name, start_time=str(self.start_time), end_time= str(self.end_time))
#    a                                                              b                              c              cc               d            ddbb aa?
1 Like

Oooops, lol.
Thanks. Do you see any other mistake? It worked, but there is another error.

Traceback (most recent call last):
  File "script.py", line 30, in <module>
    print(brunch)
TypeError: __str__ returned non-string (type NoneType)

Yeah. Your __repr__ dunder method should return a string rather than print a string. Because your method lacks an explicit return statement, None is implicitly returned by your __repr__ method, but that isn’t allowed. It must return a string.

The error message is referring to the __str__ method, but since you don’t have one, it uses __repr__ which is fine. It just has to return a string.

1 Like

Okay, thanks a lot for your help. You saved me from spending more hours trying to find “)”. :slight_smile:

1 Like