Aug-28-2020, 09:28 AM
Hi,
When running this code i should get " Hallo Zelda" but instead i get an error message. What am i doing wrong?
Any input is much appreciated!
When running this code i should get " Hallo Zelda" but instead i get an error message. What am i doing wrong?
Any input is much appreciated!
>>> class MyClass:
Greeting = ""
>>> def SayHello(self):
print("Hallo {0}".format(self.Greeting))
>>> MyClass.Greeting = "Zelda"
>>> MyClass.Greeting
'Zelda'
>>> MyInstance = MyClass()
>>> MyInstance.SayHello()
Traceback (most recent call last):
File "<pyshell>", line 1, in <module>
AttributeError: 'MyClass' object has no attribute 'SayHello'
>>>
