My code in my editor works perfectly, giving me the exact answers that are to be expected in the test, but when copying the code in the replit editor and putting it to the test, i get many errors as the following:
it shows as if the (number of days) part wasnt there, even tho in my editor the answer i get is the exact same as the expected in the test (the second smaller image is from my editor)
Your code so far
def add_time(start, duration, today = None):
time = ""
week = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
start_time = start.split(" ")
start_hora, start_minuto = start_time[0].split(':')
start_hora, start_minuto = int(start_hora), int(start_minuto)
meridiano = start_time[1]
if meridiano == 'PM':
start_hora += 12
dur_hora, dur_minuto = duration.split(':')
dur_hora, dur_minuto = int(dur_hora), int(dur_minuto)
minutos = (start_minuto + dur_minuto) % 60
tot_horas = (start_hora + dur_hora) + (start_minuto + dur_minuto) // 60
horas = tot_horas % 24
dias = tot_horas // 24
if horas >= 12:
if horas > 12:
horas %= 12 #ahora hacemos que el limite de horas sea de 12
meridiano = 'PM'
else:
meridiano = 'AM'
if horas == 0 and meridiano == 'AM':
horas = 12
time += str(horas) + ':'
if len(str(minutos)) == 1:
time += '0' + str(minutos)
else:
time += str(minutos)
time += ' ' + str(meridiano)
if dias:
if today:
today = today.title()
time += ', ' + week[(dias + week.index(today)) % 7]
if dias == 1:
time += " (next day)"
if dias > 1:
time += " (" + str(dias) + " days later)"
else:
if dias == 1:
time += " (next day)"
if dias > 1:
time += " (" + str(dias) + " days later)"
else:
if today:
time += ", " + today.title()
return time
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36 OPR/77.0.4054.275
Challenge: Time Calculator
Link to the challenge: