# Scientific Computing with Python Projects - Time Calculator

### Tell us what’s happening:

Describe your issue in detail here.

``````def add_time(start, duration,day = ''):
star_index = start.find(':')
dura_index = duration.find(':')
hours_star = int(start[:star_index])
minites_star = int(start[star_index+1:star_index+3])
hours_dura = int(duration[:dura_index])
minites_dura = int(durtion[dura_index+1:])
newhour = hours_star + hours_dura
newminites =minites_star + minites_dura

days = [(1,'Sunday'),(2,'Monday'),(3,'Thuesday'),(4,'Wednesday'),(5,'Thursday'),(6,'Friday'),(7,'Saturday')]

if newminites > 59:
newhour +=1
newminites = newminites - 60
start.replace(start[star_index+1:star_index+3],str(nweminites))
n=0
if newhour > 11 and newhour < 24:
if start.find('PM'):
n = (newhour // 24) + 1
newhour -= 12
start.replace('PM','AM')
else:
n = newhour // 24
newhour -= 12
start.replace('AM','PM')
elif newhour > 23:
if start.find('PM'):
n = (newhour // 24) + 1
newhour = newhour % 24
if newhour < 12:
start.replace('PM','AM')
else:
newhour -= 12
else:
n = newhour // 24
newhour = newhour % 24
if newhour > 11:
start.replace('AM','PM')
newhour -= 12
start.replace(start[:star_index],str(newhour))
if day != '' and n != 0:
ds =days.lower()
for v,d in ds:
if day.lower() == d:
index1 = v + n
index1 %= 7
index2 = [day_tuple[0] for day_tuple in days].index(index1)
day = days[index2][1]
if n != 0:
n = '(next day)' if n == 1 else f'({n} days later)'
if day == '':
if n ==0:
new_time = f'{start}'
else:
new_time = f'{start} {n}'
else:
if n ==0:
new_time = f'{start}, {day}'
else:
new_time = f'{start}, {day} {n}'
return new_time
``````

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.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!

Hi, welcome to the forum!
We see you have posted some code but did you have a question?

(You have not filled out the “Tell us what’s happening:” field above)