FromKeys
In [1]:
import pprint
healthcare_keys = ['patient_id', 'name', 'age', 'diagnosis', 'treatment']
healthcare_dict = dict.fromkeys(healthcare_keys)
print("Healthcare Dictionary with None values:")
pprint.pp(healthcare_dict)
default_value = 'Not Available'
healthcare_dict_with_default = dict.fromkeys(healthcare_keys, default_value)
print("\nHealthcare Dictionary with default values:")
pprint.pp(healthcare_dict_with_default)
Healthcare Dictionary with None values:
{'patient_id': None,
'name': None,
'age': None,
'diagnosis': None,
'treatment': None}
Healthcare Dictionary with default values:
{'patient_id': 'Not Available',
'name': 'Not Available',
'age': 'Not Available',
'diagnosis': 'Not Available',
'treatment': 'Not Available'}
