在子类中打印属性列表

时间:2018-02-19 17:30:54

标签: python list class

class IceCreamStand(Restaurant):
    """Represents another area of the restuarant businesss"""

    def __init__(self,  restaurant_name, cuisine_type):
        super().__init__(restaurant_name, cuisine_type)

        self.flavors = ['vanilla', 'chocolate', 'strawberry', 'peanut butter']

    def display_flavors(self):
        """displays the type of flavors offered"""

        print("We offer the following flavors at our ice cream shop: ")

        for flavor in flavors:
            print(flavor.title())


myIceCream = IceCreamStand('Nick Ice Cream Shop', 'Custerd')

myIceCream.display_flavors()

我试图在方法display_flavors(self)中打印出风味列表,似乎无法使其工作。我认为for循环存在一个问题,即没有认识到上面定义的风味......

任何帮助?

0 个答案:

没有答案