Time calculator, i really need help

so im doing the time calculator, but im getting a few bugs and my days are always 1 short, like if its 20 days ahead it reports 19 days ahead, please look into the code and help me. I will be very grateful! (im asking after trying to work it out for 3 days)

Your code so far

def add_time(start, duration, day = “Monday”):
days_of_week = {“monday”: 0, “tuesday”: 1, “wednesday”: 2, “thursday”: 3, “friday”: 4, “saturday”: 5, “sunday”: 6}
days_of_week_list = [“Monday”, “Tuesday”, “Wednesday”, “Thursday”, “Friday”, “Saturday”, “Sunday”]

# seperating start time
start_tuple = start.partition(":")
start_minutes_tuple = (start_tuple[2].partition(" "))
start_hour = int(start_tuple[0])
start_minute = int(start_minutes_tuple[0])

# seperating duration time
duration_tuple = duration.partition(":")
duration_hour = int(duration_tuple[0])
duration_minute = int(duration_tuple[2])

#ampm info
am_pm = start_minutes_tuple[2]
num_of_ampm_flips = int((start_hour + duration_hour) / 12)
am_pm_flip_dict = {"AM": "PM", "PM": "AM"}
num_of_days = int(duration_hour / 24)

#adding minutes
output_minutes = (start_minute + duration_minute)%60
if output_minutes  >= 60:
    start_hour = start_hour + 1
if output_minutes < 10:
    output_minutes = str(output_minutes)
    output_minutes = "0" + output_minutes
if output_minutes == 0:
    output_minutes = "00"

#adding hours
output_hours = (start_hour + duration_hour)%12
if output_hours == 0:
    output_hours = str(output_hours)
    output_hours = "1"

# calculating am pm
am_pm = am_pm_flip_dict[am_pm] if num_of_ampm_flips % 2 == 1 else am_pm
if (am_pm == "PM" and start_hour + (duration_hour % 12) >= 12):
    num_of_days +=1
output_hours = str(output_hours)
output_minutes= str(output_minutes)

day = day.lower()
index_for_day = int((days_of_week[day]) + num_of_days) % 7
new_day = days_of_week_list[index_for_day]


#output function
returnTime = str(output_hours) + ":" + str(output_minutes) + " " + am_pm + "," +" " + str(new_day) + " " + "(" + str(num_of_days) + " days later" + ")"


print(returnTime)

add_time(“8:16 PM”, “466:02”, “tuesday”)

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36

Challenge: Time Calculator

Link to the challenge:

Could you link to your code on replit? That will make it easier and quicker to see which test cases are problematic.

So if you add 1, you would pass all the tests? Sounds like an easy solution…
And if it causes other errors, well you might get a better insight into what’s causing the error.

I fixed, it I totally remodeled my code, but the solution would not work since I used dictionaries, and adding 1 had the possibility of shooting a out of index error, But still thanks for the help!

I fixed it now, but thanks for the offer to help!