Goal: Learn to instantiate objects and call methods.
Assignment: The class HairConditioner supports the following methods:
squeezeOut: takes no arguments, and squeezes out the conditioner;
condition: takes a single string argument, and conditions the thoughts of the subject using the product.
Assume the variable conditioner stores a reference to a HairConditioner object. Write some code that squeezes conditioner, and conditions with the message “Remember to turn down the thermostat when you go to sleep”.
THIS IS WHAT I TRIED:
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”)
AND THIS IS THE ERROR:
AttributeError: ‘HairConditioner’ object has no attribute ‘_HairConditioner__called_condition’. Did you mean: ‘_HairConditioner__called_squeeze_out’?
EVEN AFTER I CHANGED THE ATTRIBUTE THEN IT STILL SAYS I AM WRONG
Thuy Nguyen is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1