<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def append(self, item):
 """ Try to add an item to this element. If the item is of the wrong type, and if this element has a sub-type, then try to create such a sub-type and insert the item into that, instead. This happens recursively, so (in python-markup):
 L [ u'Foo' ] actually creates: L [ LE [ P [ T [ u'Foo' ] ] ] ] If that doesn't work, raise a TypeError. """


        okay = True
        if not isinstance(item, self.contentType):
            if hasattr(self.contentType, 'contentType'):
                try:
                    item = self.contentType(content=[item])
                except TypeError:
                    okay = False
            else:
                okay = False
                
        if not okay:
            raise TypeError("Wrong content type for %s: %s (%s)" % (
                self.__class__.__name__, repr(type(item)), repr(item)))

        self.content.append(item)