
class MutableTree:

    def __init__ (self):
        self.length = 0
        self.value = None

    @property
    def value (self):
        return self.__value

    @value.setter
    def value (self, x):
        self.__value = x

    def full_length (self):
        return len(self)

    def walk (self):
        return iter(())

    def __len__ (self):
        return self.length

    def __iter__ (self):
        return iter(())

    def __getitem__ (self, index):
        if self:
            return None

        else:
            raise IndexError("tree index out of range")

    def __repr__ (self):
        return "<{}>".format(self.__class__.__name__)

    def insert (self, index, node):
        self.length = 1


class MutableTree:

    def __init__ (self):
        self.child = None
        self.value = None

    @property
    def value (self):
        return self.__value

    @value.setter
    def value (self, x):
        self.__value = x

    def full_length (self):
        return len(self)

    def walk (self):
        return iter(())

    def __len__ (self):
        return 0 if self.child is None else 1

    def __iter__ (self):
        return iter(())

    def __getitem__ (self, index):
        if self:
            return None

        else:
            raise IndexError("tree index out of range")

    def __repr__ (self):
        return "<{}>".format(self.__class__.__name__)

    def insert (self, index, node):
        self.child = node

Rework tree to store inserted nodes
Rework tree to store inserted nodes

  
  class MutableTree:
  
      def __init__ (self):
-         self.length = 0
+         self.child = None
          self.value = None
  
      @property
      def value (self):
          return self.__value
  
      @value.setter
      def value (self, x):
          self.__value = x
  
      def full_length (self):
          return len(self)
  
      def walk (self):
          return iter(())
  
      def __len__ (self):
-         return self.length
+         return 0 if self.child is None else 1
  
      def __iter__ (self):
          return iter(())
  
      def __getitem__ (self, index):
          if self:
              return None
  
          else:
              raise IndexError("tree index out of range")
  
      def __repr__ (self):
          return "<{}>".format(self.__class__.__name__)
  
      def insert (self, index, node):
-         self.length = 1
+         self.child = node
  
Rework tree to store inserted nodes
## Code Before:

class MutableTree:

    def __init__ (self):
        self.length = 0
        self.value = None

    @property
    def value (self):
        return self.__value

    @value.setter
    def value (self, x):
        self.__value = x

    def full_length (self):
        return len(self)

    def walk (self):
        return iter(())

    def __len__ (self):
        return self.length

    def __iter__ (self):
        return iter(())

    def __getitem__ (self, index):
        if self:
            return None

        else:
            raise IndexError("tree index out of range")

    def __repr__ (self):
        return "<{}>".format(self.__class__.__name__)

    def insert (self, index, node):
        self.length = 1

## Instruction:
Rework tree to store inserted nodes
## Code After:

class MutableTree:

    def __init__ (self):
        self.child = None
        self.value = None

    @property
    def value (self):
        return self.__value

    @value.setter
    def value (self, x):
        self.__value = x

    def full_length (self):
        return len(self)

    def walk (self):
        return iter(())

    def __len__ (self):
        return 0 if self.child is None else 1

    def __iter__ (self):
        return iter(())

    def __getitem__ (self, index):
        if self:
            return None

        else:
            raise IndexError("tree index out of range")

    def __repr__ (self):
        return "<{}>".format(self.__class__.__name__)

    def insert (self, index, node):
        self.child = node
