---
id: 6846a1f2805ac73ce671a5d8
title: Step 8
challengeType: 20
dashedName: step-8
---

# --description--

As you learned in a previous lesson, the `enumerate` function allows to keep track of the index while looping over an iterable:

```py
person = {'name': 'John', 'age': 33}

for index, item in enumerate(person):
    print(index, item)

# 0 name
# 1 age
```

Create a `for` loop that iterates over `data`. Use the `enumerate` function to get both the index and the item in `data` at each iteration. Use `index` and `dictionary` as iteration variables.

For now use `pass` to fill the loop body.

# --hints--

You should have a `for` loop in your `validate` function.

```js
({ test: () => runPython(`
assert _Node(_code).find_function("validate").find_for_loops()[0]
`) })
```

Your `for` loop should iterate over `enumerate(data)`.

```js
({ test: () => runPython(`
assert _Node(_code).find_function("validate").find_for_loops()[0].find_for_iter().is_equivalent("enumerate(data)")
`) })
```

You should use `index` and `dictionary` as the iteration variables in your `for` loop.

```js
({ test: () => runPython(`
assert _Node(_code).find_function("validate").find_for_loops()[0].find_for_vars().is_equivalent("index, dictionary")
`) })
```

# --seed--

## --seed-contents--

```py
medical_records = [
    {
        'patient_id': 'P1001',
        'age': 34,
        'gender': 'Female',
        'diagnosis': 'Hypertension',
        'medications': ['Lisinopril'],
        'last_visit_id': 'V2301',
    },
    {
        'patient_id': 'p1002',
        'age': 47,
        'gender': 'male',
        'diagnosis': 'Type 2 Diabetes',
        'medications': ['Metformin', 'Insulin'],
        'last_visit_id': 'v2302',
    },
    {
        'patient_id': 'P1003',
        'age': 29,
        'gender': 'female',
        'diagnosis': 'Asthma',
        'medications': ['Albuterol'],
        'last_visit_id': 'v2303',
    },
    {
        'patient_id': 'p1004',
        'age': 56,
        'gender': 'Male',
        'diagnosis': 'Chronic Back Pain',
        'medications': ['Ibuprofen', 'Physical Therapy'],
        'last_visit_id': 'V2304',
    }
]

def validate(data):
    is_sequence = isinstance(data, (list, tuple))

    if not is_sequence:
        print('Invalid format: expected a list or tuple.')
        return False
        
    is_invalid = False

--fcc-editable-region--
    
--fcc-editable-region--
```
