In [10]:
#Clearing a List of Integers
patient_ages = [25, 34, 45, 52, 63]
print("Before clearing:", patient_ages)
patient_ages.clear()
print("After clearing:", patient_ages)
Before clearing: [25, 34, 45, 52, 63] After clearing: []
In [11]:
#Clearing a List of Strings
patient_names = ["Alice", "Bob", "Charlie", "Diana"]
print("Before clearing:", patient_names)
patient_names.clear()
print("After clearing:", patient_names)
Before clearing: [''''Alice'''', ''''Bob'''', ''''Charlie'''', ''''Diana''''] After clearing: []
In [12]:
import pprint
#Clearing a List of Dictionaries
patient_records = [
{"name": "Alice", "age": 25, "condition": "Hypertension"},
{"name": "Bob", "age": 34, "condition": "Diabetes"},
{"name": "Charlie", "age": 45, "condition": "Asthma"}
]
print("Before clearing:")
pprint.pp(patient_records)
patient_records.clear()
print("After clearing:")
pprint.pp(patient_records)
Before clearing: [{''''name'''': ''''Alice'''', ''''age'''': 25, ''''condition'''': ''''Hypertension''''}, {''''name'''': ''''Bob'''', ''''age'''': 34, ''''condition'''': ''''Diabetes''''}, {''''name'''': ''''Charlie'''', ''''age'''': 45, ''''condition'''': ''''Asthma''''}] After clearing: []