In [1]:
#Appending Integers
patient_ages = [25, 34, 45, 50]
new_age = 29
patient_ages.append(new_age)
print(patient_ages)
[25, 34, 45, 50, 29]
In [2]:
#Appending Strings
patient_names = ["Alice", "Bob", "Charlie"]
new_name = "Diana"
patient_names.append(new_name)
print(patient_names)
[''''Alice'''', ''''Bob'''', ''''Charlie'''', ''''Diana'''']
In [3]:
import pprint
#Appending Dictionaries
patient_records = [
{"name": "Alice", "age": 25, "condition": "Hypertension"},
{"name": "Bob", "age": 34, "condition": "Diabetes"}
]
new_record = {"name": "Charlie", "age": 45, "condition": "Asthma"}
patient_records.append(new_record)
pprint.pp(patient_records)
[{''''name'''': ''''Alice'''', ''''age'''': 25, ''''condition'''': ''''Hypertension''''}, {''''name'''': ''''Bob'''', ''''age'''': 34, ''''condition'''': ''''Diabetes''''}, {''''name'''': ''''Charlie'''', ''''age'''': 45, ''''condition'''': ''''Asthma''''}]