title: Python - Using index from tuple list, how to solve when index out of range only using while statement
body: <p>I made a while loop that :</p>
  
  <ol>
  <li>Counts daily steps in a list of tuple </li>
  <li>Returns the number of days taken for the aimed steps.</li>
  <li>Must return None if the total steps are lower than the aimed steps.</li>
  </ol>
  
  <p>This works fine until the index range exceeds the given list.</p>
  
  <p>I've attempted various ways using If statement like below but couldn't make it work.. I found it works when I change the index value > Len(step_records) but seems it get error when the index value is += 1 from the while loop.</p>
  
  <p>* I am not allowed to use for statement.</p>
  
  <hr>
  
  <pre><code>step_records = [('2010-01-01',1),
                  ('2010-01-02',2),
                  ('2010-01-03',3)]
  
  aim_steps = 7
  total_steps = 0
  index = 0
  days = 0
  
  
  if len(step_records) &gt;= index:
      while total_steps &lt; aim_steps:
          total_steps += step_records[index][1]
          index += 1
          days += 1    
      print(days)
  else:
      days = None
      print(days)    
  </code></pre>
  
  <p>results in </p>
  
  <pre><code>Traceback (most recent call last):
    File "/Users/lowden/untitled-3.py", line 13, in &lt;module&gt;
      total_steps += step_records[index][1]
  IndexError: list index out of range
  </code></pre>