Changed while true to while notdone. Converted the day of the week to lowercase in the daychange function to handle case-insensitive input. Added a global variable hourstotal to accumulate the total hours for the week.
# assignment: head1 = "weekly hours worked"
head1 = "weekly hours worked"
day_footer = "day total "
sentinel = "done" # named constant for sentinel value
hoursworked = 0 # current record hours
hourstotal = 0 # hours total for a day
prevday = "" # previous day of week
notdone = True # loop control
# print two blank lines.
print("\\\\")
# print heading.
print("\t" + head1)
# print two blank lines.
print("\\\\")
# read first record
dict1 = {"mon": 0, "tue": 0, "wed": 0, "thr": 0, "fri": 0, "sat": 0, "sun": 0}
def daychange(dayofweek, hoursworked):
global hourstotal
if dayofweek in dict1:
dict1[dayofweek] += int(hoursworked)
hourstotal += int(hoursworked)
while notdone:
dayofweek = input("enter day of the week or write 'done' to quit: ")
if dayofweek == 'done':
notdone = False
else:
hoursworked = input("enter hours worked: ")