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)

10th Feb 2020, 12:46 AM
sushil mundhra
sushil mundhra - avatar
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).
10th Feb 2020, 12:51 AM
HonFu
HonFu - avatar
+ 1
Thnx HonFu
10th Feb 2020, 4:52 AM
sushil mundhra
sushil mundhra - avatar