To start off, this is not a question for how to get a specific result, but rather about the inner workings of Python. I am pretty new to programming, so please tell me if I am using any terms incorrectly. My hypothetical is centered around a pretty rudimentary error. I try to run:
"My age is " + 46
Obviously this gives the "Can't convert 'int' object to str implicitly" error. There is no definition for adding a string to an integer, but can I create one?
My first question is whether this is possible for built-in classes like strings and integers. I looked around and don't think that it is, but if anyone knows of a way I would be interested.
My second question is if I define two new classes that behave like strings and integers in every way, but are not built-in, can I define the addition of the two classes? I know I can define the addition of the same class, but what about two different ones?
In the end, addition (whether it is directly strings and integers or two classes like strings and integers) should produce: "My age is 46" by converting the integer to a string before adding it.
Thanks in advance!