0

Python 3 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+'('+format(self.capacity+other.capacity)+'L)' a = Juice('Orange', 1.5) b = Juice('Apple', 2.0) result = a + b print(result) This is my code. It is not giving Orange&Apple(3.5L) test case is not accepting the result

30th Aug 2021, 11:28 AM
karthikeya
karthikeya - avatar
2 Answers
+ 3
Hi karthikeya! I didn't try this challenge yet. But I can assume that you're missing an extra space somewhere else since it's a hard code solution. Most probably, that missing space before parenthesis in the string returned by your __add__ function.
30th Aug 2021, 11:56 AM
Python Learner
Python Learner - avatar
0
karthikeya See your result and test case result. There is space between Apple and opening parenthesis (
30th Aug 2021, 12:12 PM
A͢J
A͢J - avatar