Build a Medical Data Validator - Step 19

Tell us what’s happening:

I’m stuck at step 19, even tho it tried everything.
I did comment out the line of age 34 but it’s still not working.

Your code so far

# User Editable Region
medical_records = [
    {
        'patient_id': 'P1001',
        # 'age': 34,
        'gender': 'Female',
        'diagnosis': 'Hypertension',
        'medications': ['Lisinopril'],
        'last_visit_id': 'V2301'
    }
]

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

    key_set = set([
        'patient_id',
        'age',
        'gender',
        'diagnosis',
        'medications',
        'last_visit_id'
    ])

    for index, dictionary in enumerate(data):
        if not isinstance(dictionary, dict):
            print(f'Invalid format: expected a dictionary at position {index}.')
            is_invalid = True

        if set(dictionary.keys()) != key_set:
            print(f'Invalid format: {dictionary} at position {index} has missing and/or invalid keys.')
            is_invalid = True

    if is_invalid:
        return False

    print('Valid format.')
    return True

validate(medical_records)
# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/152.0.0.0 Safari/537.36

Challenge Information:

Build a Medical Data Validator - Step 19

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/workshop-medical-data-validator/6846ba7ef391f007fcc37688.md at main · freeCodeCamp/freeCodeCamp · GitHub

Welcome to the forum @abeehakashan2008

You are not asked to remove any of the records.

Please reset the step and only comment out the age line. Do not modify the medical_records list by removing any of the dictionaries.

Happy coding

thanks, but it is still not working can you write me that line so that i can get help.

Try refreshing the page using CTRL + F5

You correctly commented out the code in your original post.

Happy coding

I’m sorry that i’m bothering you… but, It still not worked. I have attached the error pic too.

You should have four dictionaries in medical_records, not 1.

Make sure to reset the step to restore the seed code.

Happy coding

Thank you so much!
It works.:slightly_smiling_face: