# Scientific Computing with Python Projects - Time Calculator

i have completed the project test with vscode and return exactly what the output expected but when i paste the code & run the test it didn’ t run. Can you help me what’s wrong.

It’s not possible for me to access your code that way. You will need to copy it and share it here.

``````def add_time(start, duration), start_day=None):

#Splitting the start time to hour, minute, PM/AM
splitStart = start.split(); splitDuration = duration.split(":")
splitTime = splitStart[0].split(":"); durationHour = int(splitDuration[0]); durationMinute = int(splitDuration[1])
hour = int(splitTime[0]); minute = int(splitTime[1])

#List of the day
daysName = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]

#Check if the day is provided from perimeter
if start_day:
start = daysName.index(start_day.lower())
else:
pass

day = 0 #Initialize the day count
sign = None #Initialize the PM/AM

#Condition if the hour more than 12 convert to 24hour
if splitStart[1] == "PM":
hour = hour + 12

#calculate the duration
day = durationHour // 24; durationHourToAdd = durationHour - (day * 24)

#Check if calculated minute bigger than 60

#Checking all the possible condition for calculating hour
sign = "PM"
sign = "AM"
day += 1
sign = "PM"
sign = "AM"
sign = "AM"
sign = "AM"
day += 1

#Calculating the day string
if start_day:
for _ in range(start, day+daysName.index(start_day.lower())):
daysName[start]
start += 1
if start> len(daysName)-1:
start = 0
daysName[start]

#return the possible output
if not start_day and day == 0:
elif not start_day and day == 1:
elif not start_day and day > 1:
elif start_day and day == 0:
elif start_day and day == 1:
elif start_day and day > 1:

return new_time
``````

Thanks for the update.

There’s couple details, main reason why it might look like nothing is happening is `SyntaxError`:

``````    def add_time(start, duration), start_day=None):
^
SyntaxError: unmatched ')'
``````

Another issue is using literal `'` around the returned time. They are in the test hints to indicate that string should be returned.

ok i’ve corrected the syntax error & what do u mean by issue with using ’ ?

The `f"'(...)'"`, this is adding `'` at the start and end of the string.

still can’t run the test. It’s fine in vscode exactly the same output

``````def add_time(start, duration, start_day=None):

#Splitting the start time to hour, minute, PM/AM
splitStart = start.split(); splitDuration = duration.split(":")
splitTime = splitStart[0].split(":"); durationHour = int(splitDuration[0]); durationMinute = int(splitDuration[1])
hour = int(splitTime[0]); minute = int(splitTime[1])

#List of the day
daysName = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"]

#Check if the day is provided from perimeter
if start_day:
start = daysName.index(start_day.lower())
else:
pass

day = 0 #Initialize the day count
sign = None #Initialize the PM/AM

#Condition if the hour more than 12 convert to 24hour
if splitStart[1] == "PM":
hour = hour + 12

#calculate the duration
day = durationHour // 24; durationHourToAdd = durationHour - (day * 24)

#Check if calculated minute bigger than 60

#Checking all the possible condition for calculating hour
sign = "PM"
sign = "AM"
day += 1
sign = "PM"
sign = "AM"
sign = "AM"
sign = "AM"
day += 1

#Calculating the day string
if start_day:
for _ in range(start, day+daysName.index(start_day.lower())):
daysName[start]
start += 1
if start> len(daysName)-1:
start = 0
daysName[start]

#return the possible output
if not start_day and day == 0:
elif not start_day and day == 1:
elif not start_day and day > 1:
elif start_day and day == 0:
elif start_day and day == 1:
elif start_day and day > 1:
new_time = print("{}:{:02} {}, {} ({} days later)".format(added_hour, added_minute, sign, daysName[start].capitalize(), day))

return new_time
``````

Updated code prints the result on it own, it is expected that function will return the string. It is fine to use f-strings, but without additional `'` at the start and end.

thank for the help but now i get this error

this is the updated code

``````if not start_day and day == 0:
elif not start_day and day == 1:
elif not start_day and day > 1:
elif start_day and day == 0:
elif start_day and day == 1:
elif start_day and day > 1:
``````

If I add `print('output', add_time('3:30 PM', '2:12'))` to test your function, the output is `None`

To test

Expected time to end with `'(next day)'` when it is the next day.

`print('output', add_time('3:30 PM', '12:12'))`, it outputs `3:42 AM` which is correct, but it also needs to be `3:42 AM (next day)`
``````    elif not start_day and day == 1: