Time calculator output error

Hi Guys,

I created the code according to the requirement stated but I still cannot get the desire output.
Appreciate your expertise and time to guide me and point out my error.

Challenge: Time Calculator

Link to the challenge:

I didn’t check if the whole logic behind the solution is working, but I saw where your code first fails the test.

once a return statement is reached in a function, that function returns the result and stops being executed, so when you do:

return end_hour

the function stops and returns an integer that is your calculated end_hour.
that is not what the problem is asking you to return.

instead use a result variable that you return until it satisfies all conditions

result = "" #and update it, once all conditions are met return it in a return statement

You seem to think that if-else need a return - they don’t. Only functions themself need a return to indicate their end, as well as whatever value they should give back after the call.
If-else blocks will basically filter out lines of code, (not) executing them based on the given conditions.

Thanks for pointing out that.
I managed to reduce the failure.

Thanks for pointing out that.
I am able to clear the failure

Hi Guys,.
I am currently have 3 failures regarding on the AM and PM changes .
The following is my code.
Appreciate your expertise and time to review it.
You may find the link on the first thread

The errors are pretty clear on what’s wrong.
The reason is the special case with 12AM and 12PM, which you just have to take special measures in the code to catch.

For example you give out the time “12:04 PM Thursday (1 day later)” → but that’s 4 minutes after midnight on Friday. Hence it should be “12:04 AM Friday (2 days later)”
You already did catch if the hour would be “0” that it’s actually “12” → you basically need to do the same thing for am/pm, the day and the “days later” part.

Thanks for pointing out that

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