title: IndexError: list index out of range stair algorithm
body: <p>I want to make an algorithm that counts how many stairs can guy jump from each stair. b is his jump height and c is height of each stair.</p>
  
  <pre><code>b = 7
  c = [1, 2, 3, 4, 5, 4, 3, 2, 1]
  indx = 1
  indx1 = 1
  
  for x in c:
      while x &lt; b:
          if x + c[indx] &lt; b:
              x = x + c[indx]
              indx += 1
              print(x)
          else:
              indx1 += 1
              indx = indx1
  </code></pre>
  
  <p>This code gives me this output:
      3
      Traceback (most recent call last):
      6
        File "file location*", line 9, in 
          if x + c[indx] &lt; b:
      IndexError: list index out of range</p>
  
  <p>I don't know why it doesn't skip that if and doesn't go to the else statement...</p>