---
id: 6846d5b4d1ca2de562d6629c
title: Step 10
challengeType: 20
dashedName: step-10
---

# --description--

After your `for` loop, still inside the `validate` function, create an `if` statement. If `is_invalid` is `True`, return `False`.

# --hints--

You should have an `if` statement at the bottom of your `validate` function.

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

Your `if` statement should run when `is_invalid` is `True`.

```js
({ test: () => runPython(`
_actual = _Node(_code).find_function("validate").find_ifs()[1].find_conditions()[0]
_conditions = [
  "is_invalid",
  "is_invalid == True",
  "True == is_invalid",
  "is_invalid is True",
  "True is is_invalid",
]
assert any(_actual.is_equivalent(expected) for expected in _conditions)
`) })
```

You should return `False` inside your `if` statement.

```js
({ test: () => runPython(`
assert _Node(_code).find_function("validate").find_ifs()[1].find_bodies()[0].has_return("False")
buit_in_print = print
def custom_print(*args, **kwargs):
  pass
print = custom_print

assert validate([{}, "", 0]) == False
`) })
```

# --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
    
    for index, dictionary in enumerate(data):
        if not isinstance(dictionary, dict):
            print(f'Invalid format: expected a dictionary at position {index}.')
            is_invalid = True

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