Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First_of_Capital City solution in Speedy category for Capital City by Oleg_Novikov
class Capital:
__instance = None
def __new__(cls, name):
if Capital.__instance is None:
Capital.__instance = object.__new__(cls)
Capital.__instance._name = name
return Capital.__instance
def name(self):
return self._name
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
ukraine_capital_1 = Capital("Kyiv")
ukraine_capital_2 = Capital("London")
ukraine_capital_3 = Capital("Marocco")
assert ukraine_capital_2.name() == "Kyiv"
assert ukraine_capital_3.name() == "Kyiv"
assert ukraine_capital_2 is ukraine_capital_1
assert ukraine_capital_3 is ukraine_capital_1
print("Coding complete? Let's try tests!")
June 19, 2019
Comments: