Hey,
I am writing a basic class and I am having problems inserting arguments into the class "Dog".
Here is the source code
here is the error message:
I am writing a basic class and I am having problems inserting arguments into the class "Dog".
Here is the source code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
class Dog(): def _init_( self , name, age): self .name = name self .age = age def sit( self ): print ( self .name.title() + ' is now sitting.' ) def roll_over( self ): print ( self .name.title() + ' is now rolling over.' ) my_dog = Dog( 'Willie' , 6 ) print ( "my dog's name is " + my_dog.name.title() + "." ) print ( 'my dog is ' + str (my_dog.age) + '.' ) |
Error:Traceback (most recent call last):
File "C:/Users/maxya/PycharmProjects/classes.py", line 28, in <module>
my_dog = Dog('Willie', 6)
TypeError: Dog() takes no arguments
Thank you for your help.