Which method?

Report a typo

Which magic method do you need to define in the class Hotel so that the code after the class definition works?

class Hotel:
    def __init__(self, name, n_rooms):
        self.name = name
        self.n_rooms = n_rooms
        self.vacancy = n_rooms


rosebud = Hotel("Rosebud", 10)
# book two rooms
rosebud -= 2

Enter the name of the method without parentheses, for instance __init__.

Enter a short text
___

Create a free account to access the full topic