python代码怎样改?

img

img


class Restaurant:
    def __init__(self, restaurant_name, cuisine_type):
        self.restaurant_name = restaurant_name
        self.cuisine_type = cuisine_type

class IceCreamStand(Restaurant):

    def __init__(self, restaurant_name, cuisine_type):
        super().__init__(restaurant_name, cuisine_type)
        self.flavors = ['vanilla', 'chocolate', 'strawberry']

    def show_icecream_fiavors(self):
        for flavor in self.flavors:
            print(f"Your icecream has {self.flavors} flavor")


myicecream = IceCreamStand('haoke', 'beef')
myicecream.show_icecream_fiavors()

super.__init__(self,xxx,xxx)

第二个for循环里面的f—string里面不应该是self.flavors,而应该是flavor

检查下你的父类Restaurant类
super.__init__()#括号里的东西要跟继承父类构造函数中的内容相对应
报错显示你这里面的输入和父类不一致好像