I have tried to run this code but i keep getting this error. I dont know what is causing the error. Please can someone help me out?
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.")
Error
[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