Python 101 : The "__str__()" function - String representation of an object -
The __str__() function is called to give us the string representation of an object, it is called when we call the print() function on an object for example.
Below of a class that doesn't implement the __str__() function:
Below, we implement the __str__() function and we set it to display the "brand" and the "color" of the class "Car":
Comments