Re: Getting error on my code
Alan Gauld via Tutor <[email protected]> Fri, 31 Jan 2025 10:40:26 +0000
| Newsgroups | gmane.comp.python.tutor |
|---|---|
| Message-ID | <[email protected]> |
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 _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor