My code is as follows but is returning errors on things that come our correct, not sure what is going on
def add_time(start, duration):
am_pm = start.split()[-1]
if am_pm == "AM":
start_h = int((start.split()[0]).split(":")[0])*60
else:
start_h = (int((start.split()[0]).split(":")[0])+12)*60
start_m = int((start.split()[0]).split(":")[-1])
dur_h = int(duration.split(":")[0])*60
dur_m = int(duration.split(":")[-1])
start_both = start_h + start_m
dur_both = dur_h + dur_m
end_h24 = 0
end_h12 = 0
end_m = 0
end_time = 0
days_later = 0
end_str = ""
if (start_both + dur_both) > 1444:
end_time = (start_both + dur_both)
end_h24 = int((start_both + dur_both)/60)%24
end_m = ((start_both + dur_both)%60)
days_later = int((start_both + dur_both)/(24*60))
if end_h24 > 11:
am_pm = "PM"
else:
am_pm = "AM"
elif (start_both + dur_both) > 720:
end_time = (start_both + dur_both)
end_h24= int((start_both + dur_both)/60)
end_m = ((start_both + dur_both)%60)
if end_h24 > 11:
am_pm = "PM"
else:
am_pm = "AM"
else:
end_time = (start_both + dur_both)
end_h24 = int((start_both + dur_both)/60)
end_m = ((start_both + dur_both)%60)
if end_h24 > 11:
am_pm = "PM"
else:
am_pm = "AM"
if days_later > 1:
end_str = "(" + str(days_later)+" days later)"
elif days_later > 0:
end_str = "(next day)"
else:
end_str = ""
if end_h24 > 12:
end_h12 = end_h24 - 12
else:
end_h12 = end_h24
if len(str(end_m)) > 1:
print(str(end_h12)+ ":"+ str(end_m)+ " "+ am_pm +" "+ end_str)
else:
print(str(end_h12)+ ":0"+ str(end_m)+ " "+ am_pm +" "+end_str)```