Tell us what’s happening:
the issue which i am facing is that most of the times when the code is perfectly fine and according to the statement but the compiler just doenot submits that code which is very exhausting and i thinnk so that should be fixed very much time is wasted on that
Your code so far
medical_records = []
# User Editable Region
medical_records.append({'patient_id': 'P1001',
#'age': 34,
'gender': 'Female', 'diagnosis': 'Hypertension', 'medications': ['Lisinopril'], 'last_visit_id': 'V2301'})
# User Editable Region
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)
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/151.0.0.0 Safari/537.36
Challenge Information:
Build a Medical Data Validator - Step 19