Time Calculator project Code help

Tell us what’s happening:
Hey, I was trying to complete the Time Calculator code, however, I am facing some problems. I tried to run my code in pycharm and it ran properly without any traceback, nevertheless the print was “2” which makes no sense.
On the website itself it does not take the day statement in the function and I do not know how to circumvent this issue.

Your code so far
def add_time(start, duration, day):
#start-split
at_pos = start.split(" “)
start_time = at_pos[0]
start_AM_PM = at_pos[1]
at_pos_2 = start_time.split(”:")
start_hour = at_pos_2[0]
start_min = at_pos_2[1]
#duration-split
at_pos_3 = duration.split(":")
duration_hour = at_pos_3[0]
duration_min = at_pos_3[1]
#day
global weekday
week = [“monday”,“tuesday”,“wednesday”,“thursday”,“friday”,“saturday”,“sunday”]
if day:
weekday = day.lower()

#format 24 hour
if start_AM_PM == “PM”:
start_hour = int(start_hour) + 12

hour = 0
minutes = int(start_min) + int(duration_min)
while minutes > 60:
    minutes -= 60
    hour+=1

count = 0
final_time_hour = int(start_hour) + int(duration_hour) + int(hour)
while final_time_hour > 24:
    final_time_hour -= 24
    index = week.index(weekday)
    new_weekday = index+1
    count += 1
    
if final_time_hour > 12:
    return final_time_hour-12

if final_time_hour < 12:
    final_AM_PM = "AM"
else:
    final_AM_PM = "PM"

if weekday != new_weekday:
    new_time = str(final_time_hour)+":"+str(minutes)+" "+str(final_AM_PM)+", "+str(new_weekday)+" ("+str(count)+"days later)"
else:
    new_time = str(final_time_hour)+":"+str(minutes)+" "+str(final_AM_PM)


return new_time

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36.

Challenge: Time Calculator

Link to the challenge:

As day represents optional starting day of the week, function also needs to have day as an optional parameter.

Can I define this just via “day=None”?

Yes, that’s a good way to do that.