Find the mistakes

Report a typo

Several magic methods are defined in the class MyClass below. However, there are some mistakes in their definitions.

Find the mistakes and fix them so that the code works correctly. The __str__() method should return a string "An object of MyClass".

Tip: Pay attention to the method arguments and return types.

Write a program in Python 3
class MyClass:
n_objects = 0

def __new(self):
if cls.n_objects < 5:
cls.n_objects += 1
return object.__new__(cls)
return None

def __str__(self):
print("")
___

Create a free account to access the full topic