[Tutor] Getting error on my code

Alan Gauld alan.gauld at yahoo.co.uk
Fri Jan 31 05:40:26 EST 2025


On 31/01/2025 07:51, Dappy Jr via Tutor wrote:
> class Dog():
> 
> def _init_(self , name , age):
> self.name = name
> self.age = age
> print(self.name.title() + self.age)
> 

The init() method requires two underscores at each
end not one. With one init() is just another method
of the class and not a constructor/initializer.


Also, in future, please ensure you post in plain text
so that the indentation is preserved. Indentaton is
critical in Python and in any more complex code it
would be impossible to understand it without indentation.

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos





More information about the Tutor mailing list