Python 如何在课堂上纠正TypeError

Python 如何在课堂上纠正TypeError,python,Python,我曾尝试运行此代码,但不断出现此错误。我不知道是什么导致了这个错误。有人能帮我吗 class Dog(): """ A simple attempt to describe a dog""" def __init__(self, name, age): """ Initialize name and age attributes.""" self.name = name self.age = age def sit(self): """ Simulates

我曾尝试运行此代码,但不断出现此错误。我不知道是什么导致了这个错误。有人能帮我吗

class Dog():
    """ A simple attempt to describe a dog"""
def __init__(self, name, age):
    """ Initialize name and age attributes."""
    self.name = name
    self.age = age
def sit(self):
    """ Simulates a dog sitting in response to a command."""
    print(f"{self.name}.title() " + "is now sitting.")
def roll_over(self):
    """ Simulates a dog rolling over in response to a command."""
    print(f"{self.name}.title() " + " rolled over.")

my_dog = Dog('willie', 6)

print("My dog's name is " +  my_dog.name.title() + ".")
print("My dog is " + str(my_dog.age) + " years old.")
错误


这很简单——下课后你没有缩进任何东西。 缩进它,一切都会好起来的

班犬: 描述狗的简单尝试 定义初始自我、姓名、年龄: 初始化名称和年龄属性。 self.name=名称 self.age=年龄 迪夫西特尔夫: 模拟狗坐着响应命令。 printf{self.name}.title+现在正在运行。 def卷取机自身: 模拟狗响应命令翻滚。 printf{self.name}.title+滚动。 我的狗=狗“威利”,6 打印我的狗的名字是+my_dog.name.title+。 打印我的狗是+strmy_狗。年龄+岁。
在python中,缩进很重要


类狗:,my_Dog=Dog'willie',6此代码缺少缩进,有在线缩进检查器,以防您发现困难

这段代码没有正确缩进,它在IDE中是这样吗?是的,这正是它在我的IDE中的外观,但我无法找出缩进哪里出错了。请您为我提供任何有用的缩进检查器站点。我正在使用VisualStudio代码,缩进让我头疼。非常感谢,希望这个答案能给你很好的启示。
[Running] python -u "/Volumes/Macintosh HD2/python_project/python_work/classes.py"
Traceback (most recent call last):
  File "/Volumes/Macintosh HD2/python_project/python_work/classes.py", line 14, in <module>
    my_dog = Dog('willie', 6)
TypeError: Dog() takes no arguments

[Done] exited with code=1 in 0.055 seconds