+ 1

Fix my code, please

class Juice: def __init__(self, x, y): self.x = x self.y = y def __and__(self, other): return Juice (self.x + other.x) def __add__(self, other): return Juice(self.y + other.y) def __str__(self): return (self.x + '('+str(self.y)+'L)') first = Juice("Orange", 2) second = Juice("Apple", 1.5) result = first + second print(result.x, result.y) https://code.sololearn.com/cwiJK23KXuhA/?ref=app

11th Mar 2022, 5:26 PM
Paulo
Paulo - avatar
4 ответов
11th Mar 2022, 6:02 PM
JaScript
JaScript - avatar
+ 4
https://code.sololearn.com/catwxTpV1FRP/?ref=app
11th Mar 2022, 5:34 PM
Oma Falk
Oma Falk - avatar
+ 2
JaScript Thank you. Now I am able to reach the output.
11th Mar 2022, 6:10 PM
Paulo
Paulo - avatar
0
Oma Falk The ideal output would be "Orange&Apple (3.5L)". But thank you for your support.
11th Mar 2022, 5:40 PM
Paulo
Paulo - avatar