Is the code correct ? | Sololearn: Learn to code for FREE!
Nouvelle formation ! Tous les codeurs devraient apprendre l'IA générative !
Essayez une leçon gratuite
+ 1

Is the code correct ?

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 Juice(self.name + '&' + other.name, self.capacity + other.capacity) a = Juice('Orange', 1.5) b = Juice('Apple', 2.0) result = a + b print(result)

8th Dec 2020, 1:58 AM
Shahan Shaikh
Shahan Shaikh - avatar
1 Réponse
+ 3
Indention aside, it seems to be working properly. https://code.sololearn.com/cK0OxrU9L7Ir/?ref=app
8th Dec 2020, 2:04 AM
noteve
noteve - avatar