# Time Calculator - Feedback :)

``````def add_time(time, change, day=None):

#Varibles
hour  = int(time.split().split(':')) + int(change.split(':'))
minute = int(time.split().split(':')) + int(change.split(':'))
ampm = time.split()
days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
days_later = None
message = None

#Functions
if minute >= 60:
hour+=1
minute-=60

if ampm == 'PM':
hour+=12

days_later = hour//24

if (hour // 12) % 2 == 0:
ampm = 'AM'
else: ampm = 'PM'

if hour % 12 == 0:
hour = 12
else: hour %= 12

if day is not None:
day = f', {days[(days.index(day.capitalize()) + days_later) % 7]}'

if days_later == 1:
message = ' (next day)'
elif days_later > 0:
message = f' ({days_later} days later)'

#Result
result = f'{hour}:{minute:02d} {ampm}{day}{message}'.replace('None','')
return(result)
``````

Hi, can you provide a link to the exercise you are working on?
Also it wouldn’t hurt to tell us what kind of feedback do you need?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.