A

Admin • 802.91K Points
Coach

Q. What happens if __str__() is not defined in a class?

  • (A) __repr__() is called as fallback
  • (B) Compilation error
  • (C) Returns empty string
  • (D) Program crashes
  • Correct Answer - Option(A)
  • Views: 7
  • Filed under category Python
  • Hashtags:

Explanation by: Admin
Python will fallback to __repr__() if __str__() is not defined.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.