Tell us what’s happening:
everything is fine and working except the test 4 that idk how it is not working and what’s the input that doesn’t fit!
Your code so far
def add_time(start, duration, dayOfTheWeek = ''):
dayOfTheWeekLower = dayOfTheWeek.lower()
startTime, amPm = start.split()
startTimeHoure, startTimeMinuts = startTime.split(':')
durationHoure, duraiotnMinuts = duration.split(':')
daysOfTheWeek = {'sunday':1 ,'monday': 2,'tuesday': 3, 'wednesday': 4, 'thursday': 5, 'friday':6, 'saturday':7}
# from 12 houre system to 24 houre system
conversion = 12 if amPm == 'PM' else 0
newWholeTimeMinuts = ((int(startTimeHoure)+conversion)*60) + int(startTimeMinuts) + (int(durationHoure)*60) + int(duraiotnMinuts)
newTimeHoures = newWholeTimeMinuts//60
newTimeMinuts = str(newWholeTimeMinuts%60) if len(str(newWholeTimeMinuts%60)) == 2 else f'0{str(newWholeTimeMinuts%60)}'
dayOfTheWeekIndex = daysOfTheWeek[dayOfTheWeekLower] if dayOfTheWeek != '' else 0
daysPassed = 0
while newTimeHoures>=24:
newTimeHoures -= 24
dayOfTheWeekIndex += 1
daysPassed += 1
while dayOfTheWeekIndex > 7:
dayOfTheWeekIndex -= 7
if newTimeHoures>12:
newTimeHoures -=12
amPm = 'PM'
else:
amPm = 'AM'
if newTimeHoures<1:
newTimeHoures = 12
for day, index in daysOfTheWeek.items():
if index == dayOfTheWeekIndex:
dayOfTheWeekResult = day
daysPassedAya = ''
if daysPassed == 0:
pass
elif daysPassed == 1:
daysPassedAya = ' (next day)'
else:
daysPassedAya = f' ({daysPassed} days later)'
dayOfTheWeekStr = '' if dayOfTheWeek == '' else ', '+ str(dayOfTheWeekResult).capitalize()
new_time = f'{newTimeHoures}:{newTimeMinuts} {amPm}{dayOfTheWeekStr}{daysPassedAya}'
return new_time
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36
Challenge Information:
Build a Time Calculator Project - Build a Time Calculator Project