Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Create restaurant class with restaurant object and describe_restaurant function
- class restaurant:
- def __init__(self, n, restaurant_name, cuisine_type):
- self.n = n
- self.restaurant_name = restaurant_name
- self.cuisine_type = cuisine_type
- def describe_restaurant(self):
- print("{} serves {}".format(restaurant.restaurant_name, restaurant.cuisine_type))
- #localplaces will contain the restaurant objects
- localplaces = []
- n = len(localplaces)
- active = True
- while active:
- localplaces.append(restaurant(n, input("Restaurant Name: "), input("Cuisine type: ")))
- repeat = input("Do you want to add another item?: ")
- if repeat.strip().lower() in ["n", "no"]:
- active = False
- else:
- while repeat.strip().lower() not in ['y', 'yes', 'n', 'no']:
- repeat = input("Add another item? [y/n]: ")
- #loop through localplaces printing the object info as defined by the
- for restaurant in localplaces:
- print("n" + restaurant.describe_restaurant().format)
- Restaurant Name: bobs
- Cuisine type: burgers
- Do you want to add another item?: n
- bobs serves burgers
- Traceback (most recent call last):
- File "C:/Users/nicholl/PycharmProjects/untitled/Coordinates.py", line 24, in <module>
- print("n" + restaurant.describe_restaurant().format)
- AttributeError: 'NoneType' object has no attribute 'format'
- Restaurant Name: bobs
- Cuisine type: burgers
- Do you want to add another item?: n
- bobs serves burgers
- Traceback (most recent call last):
- File "C:/Users/user/PycharmProjects/Test/Test11111c.py", line 24, in <module>
- print("n" + restaurant.describe_restaurant())
- TypeError: can only concatenate str (not "NoneType") to str
Add Comment
Please, Sign In to add comment