title: checking if a min heap array is valid
body: <p>I have this function def validate(self) which should check if a given array is a valid min heap. I think it works but because my arrays have None at the beginning like [None, 2, 3, 5] it seems to run into problems and give me the error <code>'&lt;' not supported between instances of 'int' and 'NoneType'</code></p>
  <p>How can i skip over the none value in my code?</p>
  <pre><code>def validate(self):
      &quot;&quot;&quot;
      Validates the heap. Returns True if the heap is a valid min-heap, and
      False otherwise.
  
      &quot;&quot;&quot;
  
      n = self.__len__() 
      for i in range(int((n - 2) / 2) + 2):
  
          if self._items[2 * i + 1] &lt; self._items[i]: 
              return False
  
          if (2 * i + 2 &lt; n and self._items[2 * i + 2] &gt; self._items[i]): 
              return False
      return True
  </code></pre>
  <p>New code:</p>
  <pre><code>def validate(self):
      &quot;&quot;&quot;
      Validates the heap. Returns True if the heap is a valid min-heap, and
      False otherwise.
  
      &quot;&quot;&quot;
  
      n = self.__len__() 
      for i in range(int((n - 2) / 2) + 2):
          if self._items[i] != None:
              if self._items[2 * i + 1] &lt; self._items[i]: 
                  return False
  
          if (2 * i + 2 &lt; n and self._items[2 * i + 2] &gt; self._items[i]): 
              return False
  </code></pre>
  <p>Error:</p>
  <pre><code>  File &quot;&lt;doctest __main__.MinHeap.validate[8]&gt;&quot;, line 1, in &lt;module&gt;
      h.validate()
    File &quot;x-wingide-python-shell://114699264/2&quot;, line 219, in validate
  TypeError: '&gt;' not supported between instances of 'int' and 'NoneType'
  </code></pre>