Задание: класс HairConditioner поддерживает следующие методы:
- < ли>: не принимает аргументов и выжимает кондиционер;
Код: Выделить всё
squeezeOut - : принимает один строковый аргумент и определяет мысли субъекта, использующего продукт.
Код: Выделить всё
condition
Напишите код, который сжимает кондиционер и создает условия с сообщением «Не забудьте выключить термостат, когда ложитесь спать». p>
ВОТ ЧТО Я ПРОБОВАЛ:
Код: Выделить всё
class HairConditioner:
def __init__(self):
self.__called_squeeze_out = False
def squeezeOut(self):
print("Squeeze out")
self.__called_squeeze_out = True
def called_condition(self, subject):
print(f"Conditions the thoughts of the subject using the product {subject}")
prototype284 = HairConditioner()
prototype284.squeezeOut()
called_squeeze_out = getattr(prototype284, "_HairConditioner__called_squeeze_out", None)
print(f"Called attribute value: {called_squeeze_out}")
prototype284.called_condition("Hello World")
Код: Выделить всё
AttributeError: 'HairConditioner' object has no attribute '_HairConditioner__called_condition'. Did you mean: '_HairConditioner__called_squeeze_out'?
Подробнее здесь: https://stackoverflow.com/questions/790 ... nd-methods
Мобильная версия