Put in order · Python course · Module 3: Object-Oriented Programming

print() and __str__

Arrange what happens after calling print(lion) on an object with a __str__ method:

Items to put in order

  • print() converts the argument to text: str(lion)
  • The text returned by __str__ appears on the screen
  • Call print(lion)
  • str() calls the method lion.__str__()

You can check the correct answer by solving this task in the CodeWorlds game.