Oct-23-2023, 03:23 PM
Hi,
I am a beginner and learning python basics from book Python Crash Course but can't figure this out
:
My dog name is Atos.
My dog is 8 years old.
I am a beginner and learning python basics from book Python Crash Course but can't figure this out

class Dog(): """A simple attempt to model a dog.""" def __init__(self, name, age): """Initialize name and age attributes.""" self.name = name self.age = age def sit(self): """Simulate a dog sitting in response to a command.""" print(self.name.title() + " is now sitting.") def roll_over(self): """Simulate rolling over in response to a command.""" print(self.name.title() + " rolled over!") #Making an Instance from a Class class Dog(): my_dog = Dog('Atos', 8) print("My dog name is " + my_dog.name.title() + ".") print("My dog is " + str(my_dog.age) + " years old.") #Accessing Attributes #Calling Methods class Dog(): my_dog = Dog('Atos', 8) my_dog.sit() my_dog.roll_over()and I am getting this output:
My dog name is Atos.
My dog is 8 years old.
Error:Traceback (most recent call last):
File "C:\Users\User\Desktop\exercise.py", line 25, in <module>
class Dog():
File "C:\Users\User\Desktop\exercise.py", line 26, in Dog
my_dog = Dog('Atos', 8)
TypeError: Dog() takes no arguments
could someone pls help