Предизвикателства > Haunted mansion > Решения > Решението на Камелия Тодорова

Резултати
1 точки от тестове
0 точки от учител

1 точки общо

1 успешни теста
0 неуспешни теста
Код

 1class HauntedMansion:
 2    def __init__(self, **kwargs):
 3        for key, value in kwargs.items():
 4            self.__setattr__(key, value)
 5    
 6    def __getattr__(self, name):
 7        return "Booooo, only ghosts here!"
 8    
 9    def __setattr__(self, name, value):
10        object.__setattr__(self, f"spooky_{name}", value)
11    

.
----------------------------------------------------------------------
Ran 1 test in 0.000s

OK

Дискусия
История

f1f1
2class HauntedMansion:2class HauntedMansion:
3    def __init__(self, **kwargs):3    def __init__(self, **kwargs):
4        for key, value in kwargs.items():4        for key, value in kwargs.items():
n5            self.__setattr__(key,value)n5            self.__setattr__(key, value)
6    6    
t7    def __getattr__(self, name_):t7    def __getattr__(self, name):
8        return "Booooo, only ghosts here!"8        return "Booooo, only ghosts here!"
9    9    
10    def __setattr__(self, name, value):10    def __setattr__(self, name, value):
11        object.__setattr__(self, f"spooky_{name}", value)11        object.__setattr__(self, f"spooky_{name}", value)
12    12    
1313
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op