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
