Solution Review: Implement a Print Method

This lesson discusses the __str__ method in Python for the string representation of an object.

We'll cover the following

Solution:

In Python, and in many other languages for that matter, if we make a class and print an instance of that class the output may vary every time. It prints the address of the object in memory. Consider the following code:

Get hands-on with 1200+ tech skills courses.