class Restaurant:
def __init__(self,
name, website, cuisine):
self.name = name
self.website = website
self.cuisine = cuisine
dominoes = Restaurant("Dominoes", "www.dominoes.co.uk", "pizza")
yosushi = Restaurant("Yo Sushi!", "www.yosushi.co.uk", "sushi")
fiveguys = Restaurant("Five Guys", "www.fiveguys.co.uk" ,"burger")
restaurants = dict()
restaurants["Dominoes"] = dominoes
restaurants["Yo Sushi!"] = yosushi
restaurants["Five Guys"] = fiveguys
in_loop = True
while in_loop:
print("CS1822 Restaurant DB")
print("1. Display restaurant list")
print("2. Add a restaurant")
print("3. Exit")
choice = input("Please enter your choice: ")
if choice == "1":
for name in restaurants:
restaurant = restaurants[name]
print(name, "-", restaurant.website, "-", restaurant.cuisine)
elif choice == "2":
name = input("Enter restaurant name: ")
website = input("Enter website: ")
cuisine = input("Enter cuisine: ")
x = Restaurant(name, website, cuisine)
restaurants.append(x)
else:
print("Goodbye!")
break
I do not understand how to solve the error message:
Run error Traceback (most recent call last): File "tester.python3", line 55, in restaurants.append(x) AttributeError: 'dict' object has no attribute 'append'
I am trying to add a user input restaurant and its features to the list of Restaurants.