Del
In [1]:
import pprint
In [2]:
# Removing a Patient’s Record
patients = {
"patient_001": {"name": "John Doe", "age": 30, "condition": "Hypertension"},
"patient_002": {"name": "Jane Smith", "age": 25, "condition": "Asthma"},
"patient_003": {"name": "Emily Davis", "age": 45, "condition": "Diabetes"}
}
print("current")
pprint.pp(patients)
del patients["patient_002"]
print("new")
pprint.pp(patients)
current
{'patient_001': {'name': 'John Doe', 'age': 30, 'condition': 'Hypertension'},
'patient_002': {'name': 'Jane Smith', 'age': 25, 'condition': 'Asthma'},
'patient_003': {'name': 'Emily Davis', 'age': 45, 'condition': 'Diabetes'}}
new
{'patient_001': {'name': 'John Doe', 'age': 30, 'condition': 'Hypertension'},
'patient_003': {'name': 'Emily Davis', 'age': 45, 'condition': 'Diabetes'}}
In [3]:
# Removing a Specific Detail from a Patient’s Record
patients = {
"patient_001": {"name": "John Doe", "age": 30, "condition": "Hypertension"},
"patient_002": {"name": "Jane Smith", "age": 25, "condition": "Asthma"},
"patient_003": {"name": "Emily Davis", "age": 45, "condition": "Diabetes"}
}
print("current")
pprint.pp(patients)
del patients["patient_003"]["condition"]
print("new")
pprint.pp(patients)
current
{'patient_001': {'name': 'John Doe', 'age': 30, 'condition': 'Hypertension'},
'patient_002': {'name': 'Jane Smith', 'age': 25, 'condition': 'Asthma'},
'patient_003': {'name': 'Emily Davis', 'age': 45, 'condition': 'Diabetes'}}
new
{'patient_001': {'name': 'John Doe', 'age': 30, 'condition': 'Hypertension'},
'patient_002': {'name': 'Jane Smith', 'age': 25, 'condition': 'Asthma'},
'patient_003': {'name': 'Emily Davis', 'age': 45}}
