# Appointments
#   maintains a calendar of afternoon appointments, noon through 4pm
# assumed input: a series of requests of these three forms:
#   (i) M  (for ''Make a new appointment'')
#          followed by the time, typed in the format,  hh:mm
#          followed by the appointment, typed on a single line
#   (ii) V (for ''View all appointments)
#   (iii) Q (for ``Quit'')
# output: when  V  is typed, all appointments are printed

# Data structure:  calendar  remembers all appointments:
calendar = [[], [], [], [], []]  

more_requests = True

while more_requests :

    request = raw_input("\nType request: M(ake appt), V(iew appts), Q(uit): ")
    code = request[0].upper()  # get first letter, make upper case

    if code == "Q" :  # Quit
        more_requests = False

    elif code == "V" : # View all appointments
        print "Your appointments: "
	for hour in calendar :
	    for appointment in hour :
	        print appointment
            
    elif code == "M" : # Make a new appointment
        # read the time of the appointment:
	appt_time = raw_input("Type appt. time (hh:mm): ")

        # read the appointment:
	appt = raw_input("Type your appointment: ")

        # save it in the calendar:

	# split the time in two, into a list of hours and minutes:
	hour_and_minutes = appt_time.split(":")  
	
	# get the hours part from the list,  [hours, minutes]:
	appt_hour = int(hour_and_minutes[0])

        if appt_hour == 12 :   # noon hour is 0-hour
	    appt_hour = 0
	new_appt = appt_time + ": " + appt
      
        # add the new appointment to the end of the list:
	calendar[appt_hour] = calendar[appt_hour] + [new_appt]

    else :
        print "I don't understand your request; please try again."

print
print "Have a nice day."
raw_input("press Enter to finish")