I'm trying to understand how parent and child classes in Python work and I ran into this seemingly simple problem:
class parent(object):
    def __init__(self):
        self.data = 42
class child(parent):
    def __init__(self):
        self.string = 'is the answer!'
    def printDataAndString(self):
        print( str(self.data) + ' ' + self.string )
c = child()
c.printDataAndString()
I'm expecting the string 42 is the answer! but I get
AttributeError: 'child' object has no attribute 'data'
What am I missing?
I experimentated with pass and also super(parent,...) but couldn't get it right.
 
     
    