# Any tips on making my code more streamlined?

I have finished the Time Calculator assignment and submitted it, however, my code seems super wordy and very messy. Does anyone with more coding experience have any suggestions for reducing the size of my code?

``````def add_time(start, duration, day = None) :

start = start.split()
ap = start[1].upper()
start = start[0].split(':')
duration = duration.split(':')
s_hour = int(start[0])
s_minute = int(start[1])
d_hour = int(duration[0])
d_minute = int(duration[1])
aplist = ['AM', 'PM']

apcount = 0
mcount = (s_minute + d_minute)
hcount = (s_hour + d_hour)
dcount = 0

if mcount > 60 :
hcount += 1
mcount -= 60

while hcount > 12 :
if hcount % 36 != 0 :
dcount = dcount + 0.5
apcount += 1
hcount -= 12
while hcount == 12 :
apcount += 1
break

if (apcount % 2) != 0 :
if ap == aplist[1] :
ap = aplist[0]
dcount = (apcount / 2) + 0.5
dcount = round(dcount)
elif ap == aplist[0] :
ap = aplist[1]

dcount = int(dcount)
mcount = int(mcount)
hcount = int(hcount)

if day != None :

day = day.lower()
daydic = {1: 'monday', 2: 'tuesday', 3: 'wednesday', 4: 'thursday', 5: 'friday', 6: 'saturday', 7: 'sunday'}
dkey_list = list(daydic.keys())
dval_list = list(daydic.values())
dposition = dval_list.index(day)
sday = dkey_list[dposition]
sdaycount = dcount + sday

while sdaycount > 7 :
sdaycount -= 7

if dcount == 1 :
elapsed_time = str(hcount) + ':' + (str(mcount).zfill(2)) + ' ' + str(ap) + ',' + ' ' + str(daydic.get(sdaycount)).capitalize() + ' ' + '(' + 'next day' + ')'
return elapsed_time

if dcount == 0 :
elapsed_time = str(hcount) + ':' + (str(mcount).zfill(2)) + ' ' + str(ap) + ',' + ' ' + str(daydic.get(sdaycount)).capitalize()
return elapsed_time

if dcount > 1 :
elapsed_time = str(hcount) + ':' + (str(mcount).zfill(2)) + ' ' + str(ap) + ',' + ' ' + str(daydic.get(sdaycount)).capitalize() + ' ' + '(' + str(dcount) + ' '+ 'days later' + ')'
return elapsed_time

if dcount == 1 :
elapsed_time = str(hcount) + ':' + (str(mcount).zfill(2)) + ' ' + str(ap) + ' '  + '(' + 'next day' + ')'
return elapsed_time
if dcount > 1 :
elapsed_time = str(hcount) + ':' + (str(mcount).zfill(2)) + ' ' + str(ap) + ' ' + '(' + str(dcount) + ' ' + 'days later' + ')'
return elapsed_time
if dcount == 0 :
elapsed_time = str(hcount) + ':' + (str(mcount).zfill(2)) + ' ' + str(ap)
return elapsed_time

``````