0
Where i am mistaken
class Dog: def __init__(self, name): self.name = name class Cat: def __init__(self,name): self.name = name def__radd__(self,other): return "\n".join(self.name, other.name) dog1 = Dog("Harry") cat1 = Cat("Ella") print(dog1 + cat1)
2 Antworten
+ 2
Only two mistakes in this part:
def __radd__(self,other):
return "\n".join((self.name, other.name))
One space missing after def, and a set of brackets missing (join needs an iterable).
+ 1
Thnx HonFu