[Tutor] Getting error on my code
Leam Hall
leamhall at gmail.com
Fri Jan 31 07:36:20 EST 2025
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
More information about the Tutor
mailing list