新手学习,求教大佬们是啥错误,应该怎么改代码lei
class Dog():
def init(self,name,age):
self.name = name
self.age = agedef sit(self):
print(self.name.title() + "is now sitting.")def roll_over(self):
print(self.name.title() + "is now sitting.")my_dog = Dog('willie',6)
print("My dog's name is" + my_dog.name.title()+".")
My dog's name isWillie.
print("My dog is" + str(my_dog.age)+"years old.")
My dog is6years old.
my_dog.sit()
Traceback (most recent call last):
File "", line 1, in
my_dog.sit()
AttributeError: 'Dog' object has no attribute 'sit'