# Scientific Computing with Python Projects - Time Calculator

Hello! I am finishing this project.
(I’m learning and you will see that the code is rustic but I managed to make it do what I want)
However, in the execution of the tests, there is one that DOES NOT pass.

You will see that the program passed the other tests where it does indicate “next day” when it is a new day and in the various tests it performs, it works.
Which is what the platform expects with that statement ?

``````def add_time(start, duration, day=''):
days = [(1, 'Monday'), (2, 'Tuesday'), (3, 'Wednesday'), (4, 'Thursday'), (5, 'Friday'), (6, 'Saturday'),
(7, 'Sunday')]
if len(start) == 8:  # la hs es entre 10 y 12
hs = int(start[0:2])
min = int(start[3:5])
comp = (start[-2:])
else:  # la hs es entre 0 y 9
hs = int(start[0])
min = int(start[2:4])
comp = (start[-2:])
Am = False if comp == "PM" else True  # bandera cambia segun AM o PM
duration = duration.split(":")

if AddHs == 0 and AddMin == 0:  # ingreso de 0:00 para devolver la hora inicial.
return start

# suma de valores
cont = 0

if min > 59:
hs += 1  # si minutos es mayor a 60, agrega una hs mas
min = min % 60
if hs >= 24:
cont = hs // 24  # contador de dias
cont+=1
hs = hs % 24
#cont += 1 if hs > 12 else 0

if hs >= 12 and hs < 24:  # config si el resultado es entre 13 y 23
hs = hs - 12
Am=not Am
hs= 12 if hs==0 else hs

ban = True if cont == 0 else False

# calculo de dias
if day != '' and cont != 0:
for val, dia in days:
if day.lower() == dia.lower():
aux = val + int(cont)  # suma el valor de la tupla con la cant de dias que pasaron
aux = aux % 7 if aux > 7 else aux  # si la suma sobrepasa 7, asigna el valor correcto a la semana
index = [day_tuple[0] for day_tuple in days].index(aux)
day = days[index ][1]

if cont != 0:
cont = '(next day)' if cont == 1 else f'({cont} days later)'  # calcula dias que pasaron

min = '0' + str(min) if len(str(min)) == 1 else str(min)  # configura los minutos
comp = 'AM' if Am else 'PM'

if day == '':
if ban:
new_time = f'{str(hs)}:{min} {comp}'  # formato debe ser '2:59 AM'
else:
new_time = f'{str(hs)}:{min} {comp} {cont}'  # formato debe ser '2:59 AM, (next day)'
else:
if ban:
new_time = f'{str(hs)}:{min} {comp}, {day}'
else:
new_time = f'{str(hs)}:{min} {comp}, {day} {cont}'  # formato debe ser '2:59 AM, Sunday (next day)'

return new_time

``````

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

### Challenge Information:

Scientific Computing with Python Projects - Time Calculator

You appear to have created this post without editing the template. Please edit your post to Tell us what’s happening in your own words.
Learning to describe problems is hard, but it is an important part of learning how to code.
Also, the more you say, the more we can help!

I have solved it. The problem was that it determined the days passed by simply dividing the hours by 24, thinking that days only pass when 24 hours pass, but in the event that it is 11:59 pm and two seconds are added, it must show another day. I solved it with a perhaps primitive arrangement but I approved that project.

``````    if Am==False and hs >11 and hs<24: