+ 2
Help pls 🥺🙏 : python
class Juice: def __init__(self, name, capacity): self.name = name self.capacity = capacity def __str__(self): return (self.name + ' ('+str(self.capacity)+'L)') a = Juice('Orange', 1.5) b = Juice('Apple', 2.0) result = a + b print(result) What's wrong with my code
2 Antworten
+ 7
Hrithika Reddy ,
as lisa already mentioned, you should repeat some parts of the "python core" tutorial.
have a look at the oop part, lesson 75.1 and look for magic methods.
+ 3
Please READ the TASK DESCRIPTION again: In the box it says, we should overload the __add__ operator. Your code has not defined the behavior for __add__ yet.