python教程出错不懂哪里有问题求解?

class hotdog:

    def __init__(self):

        self.cooked_level = 0

        self.cooked_string = "raw"

        self.condiments = []

        

    def cook(self ,time):

        self.cooked_level = self.cooked_level + time

        if self.cooked_level > 8:

            self.cooked_setring = "charcoal"

        elif self.cooked_level > 5:

            self.cooked_string = "welldone"

        elif self.cooked_level > 3:

            self.cooken_string = "menium"

        else:

            self.cooked_string = "raw"

mydog = hotdog()

print mydog.cooked_level

print mydog.cooked_string

print mydog.condiments

print " now i'm going to cook the hotdog"

mydog.cook(4)

print mydog.cooked_level

print mydog.cooked_string


以下是输出

0

raw

[]

 now i'm going to cook the hotdog

4

raw这里为什么还是raw啊

看教程上输出应该是menium

我除了大小写其他的完全抄的教程


慕粉1628552447
浏览 1762回答 1
1回答

孤独的小猪

你好,经过仔细观察,你判断当大于3的时候,self.cooked_string拼写错误。修正后,结果就是正确的了。如下图:
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python