Build a Medical Data Validator - Step 9

Tell us what’s happening:

Same issue on step 9. I am baffled if I get this to work properly (can even step thru individual iterations of the for loop and the embedded if ) in SPYDER6 but get them during “your” code checker !!!

Your code so far

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',
    }
]

# User Editable Region


def validate_dict_format(dictionary):
    is_invalid = False
    for index, item in enumerate(dictionary):
        if not isinstance(item, dict):
            print(f"Invalid format: expected a dictionary at position {index}.")
            is_invalid = True
    return is_invalid



# User Editable Region

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/145.0.0.0 Safari/537.36

Challenge Information:

Build a Medical Data Validator - Step 9

It looks like you’ve changed what the testing program requires for the naming conventions of the function and the variables used within that function. Syntactically you are correct. But you need to follow the instructions, including naming conventions, within the course in order to get the appropriate results.

1 Like

I cant spot anymore differences in variable names, after 55 years of programming in all sort of languages, latest Python 2.7 I wanted to upgrade myself to Python 3 so I could try my hand a AI, but now I am ready to throw in the towel.

The actual function name is validate and the variable that is set for the dictionary is dictionary not item as you have it. You can’t change the names of the function or the items. You should only edit within the highlighted editable region.

Just reset the lesson and you’ll be fine.

The red arrow in this image is the user editable region, and the teal arrow is how to reset the lesson.

Thanks, in Step 13 it says turn medical_records into a strin, HOW?

I tried

####

Convert dictionary to string

medical_records_str = str(medical_records)
validate(medical_records_str)

###

Or do you mean delete the whole dictionary and then declare it as a string?

but that only works in outside compiler

What they mean is to convert medical_records into a string by setting that very same variable name to a string version of the variable.

i.e. this code here (hidden by spoiler tag, click to reveal)

please don’t post solution code

this step will pass in any way you make medical_records a string

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.