Juice Maker
class Juice(): def __init__(self, name, capacity): self.name = name self.capacity = capacity def __str__(self): return (self.name + ' ('+str(self.capacity)+'L)') def __add__(self,other): return self.name+"&"+other.name+ '('+str(self.capacity+other.capacity)+'L'+")" a = Juice('Orange', 1.5) b = Juice('Apple', 2.0) #b=Juice('Banana',3.5) result = a + b print(result) my output : Orange&Apple(3.5L) expected output: Orange&Apple (3.5L) What is wrong with my code? I got the same expected result but it shows wrong answer. ------------------------------------------------------------------------------------------- Another attempt : class Juice: def __init__(self, name, capacity): self.name = name self.capacity = capacity def __str__(self): return (self.name + ' ('+str(self.capacity)+'L)') def __add__(self,other): y=self.name+"&"+other.name z='('+str(self.capacity+other.capacity)+'L'+")" return y.__add__(z) a = Juice('Orange', 1.5) b = Juice('Apple', 2.0) result = a + b print(result)