# Initialize an empty dictionary to store patient names and their pill amounts
patients = {}
# Loop until the user types "exit"
while True:
# Ask the user for a patient name or "exit"
name = input("Enter a patient name or type 'exit' to quit: ")
# If the user types "exit", break out of the loop
if name == "exit":
break
# If the patient name is not already in the dictionary, add it with a starting pill amount of 0
if name not in patients:
patients[name] = 0
# Ask the user for the number of pill capsules the patient takes
pills = input("Enter the number of pill capsules taken by {}: ".format(name))
# Try to convert the input to an integer, and update the patient's pill amount
try:
pills = int(pills)
patients[name] += pills
except ValueError:
print("Invalid input: please enter a whole number")
# Ask the user if they want to see the total pill amounts for each patient
response = input("Would you like to see the total pill amounts for each patient? (y/n) ")
if response.lower() == "y":
for name in patients:
print("{}: {} pill capsules".format(name, patients[name]))