[Tutor] Getting error on my code

Dappy Jr oladaposegun62 at gmail.com
Fri Jan 31 02:51:37 EST 2025


class Dog():

def _init_(self , name , age):
self.name = name
self.age = age
print(self.name.title() + self.age)

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.')


I'm trying to create a class Dog and print with attributes name and age as
'willie' , 6years old. Whenever i run the code i keep getting Dog() takes
no argument error message..

Traceback (most recent call last):
  File "C:\Users\OLADAPO JR\python_work\Classes\dog.py", line 8, in <module>
    my_dog = Dog('willie' , 6)
             ^^^^^^^^^^^^^^^^^
TypeError: Dog() takes no arguments

My OS = Windows
Python Version = 3.12


More information about the Tutor mailing list