title: TypeError: list indices must be integers, not float in heapsort
body: <p>I can't find my mistake in here, if someone can help me would be great.</p>
  
  <pre><code>def heapsort (lista) :
      n= len(lista)-1
      k= n/2 
      while (k&gt;0) :
          downheap(lista,n,k) 
          k-=1 
      while (n&gt;=0) :
          (lista[1]),(lista[n])=(lista[n]),(lista[1]) 
          n-=1 
          return downheap(lista, n, 1) 
      return lista  
  
  def downheap (lista, n, k) :
      v= lista[k] 
      while (k&lt;=(n/2)) :
          j=k+k
          if (j&lt;n and (lista[j]) == (lista[j])) :
              break
          (lista[k]) = (lista[j]) 
          k = j 
      lista[k] = v 
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>&gt;&gt;&gt; heapsort([4,2,3,1])
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
    File "&lt;stdin&gt;", line 5, in heapsort
    File "&lt;stdin&gt;", line 2, in downheap
  TypeError: list indices must be integers, not float
  </code></pre>