Build a Medical Data Validator - step 35

Each item in the medications list should be a string. In this step and the next one you’ll write an expression to check that. Use the and operator to add another expression to the value of the medications key.

On the right side of the and operator, use the list comprehension syntax to create a list made by evaluating isinstance(i, str) for each i in medications.

This is my code so far:

constraints = {

    'patient_id': isinstance(patient_id, str) and re.fullmatch('p\\d+', patient_id, re.IGNORECASE),

    'age': isinstance(age, int) and age >= 18,

    'gender': isinstance(gender, str) and gender.lower() in ('male', 'female'),

    'diagnosis': isinstance(diagnosis, str) or diagnosis is None,

    'medications': isinstance(medications, list)

}

return constraints

Hello

Please link to the url of the step you are on.

For future reference you can use the ask for help button.

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Help button located on the challenge.

The Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.