I made a while loop that :

1. Counts daily steps in a list of tuple
2. Returns the number of days taken for the aimed steps.
3. Must return None if the total steps are lower than the aimed steps.

This works fine until the index range exceeds the given list.

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.

\* I am not allowed to use for statement.

---

```
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) >= index:
    while total_steps < aim_steps:
        total_steps += step_records[index][1]
        index += 1
        days += 1    
    print(days)
else:
    days = None
    print(days)    

```

results in 

```
Traceback (most recent call last):
  File "/Users/lowden/untitled-3.py", line 13, in <module>
    total_steps += step_records[index][1]
IndexError: list index out of range

```