Re: Getting error on my code
Leam Hall via Tutor <[email protected]> Fri, 31 Jan 2025 06:36:20 -0600
| Newsgroups | gmane.comp.python.tutor |
|---|---|
| Message-ID | <[email protected]> |
On 1/31/25 06:10, Alan Gauld via Tutor wrote: > On 31/01/2025 10:46, Leam Hall via Tutor wrote: > >>> def_init_(self , name , age): >>> self.name = name >>> self.age = age >>> print(self.name.title() + self.age) > >> 2. Made the age a string in the __init__ print method. > > As a matter of interest, why? > print() converts its arguments to strings internally > so why the explicit conversion? > Sorry, coffee still kicking in. If we redo the print statement without the concat, it does the conversion: print(self.name.title(), self.age) Leam Linux Software Engineer (reuel.net/career) Scribe: The Domici War (domiciwar.net) Coding Ne'er-do-well (github.com/LeamHall) Between "can" and "can't" is a gap of "I don't know", a place of discovery. For the passionate, much of "can't" falls into "yet". -- lh Practice allows options and foresight. -- lh _______________________________________________ Tutor maillist - [email protected] To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor