I ran the code below, by calling the function in the constructor
First --
>>> class PrintName:
... def __init__(self, value):
... self.
You need to call self.printName
since your function is a method belonging to the PrintName class.
Or, since your printname function doesn't need to rely on object state, you could just make it a module level function.
class PrintName:
def __init__(self, value):
self._value = value
printName(self._value)
def printName(value):
for c in value:
print c