Time Calculator - errors in the test module?

Hi,
I’ve constructed the ‘Time Calculator’ in Python, and as far as I can see, my code is doing its job. However, when I click ‘run’ to check whether the code passes the tests, it fails 2 out of the 12 tests, and I get the following two weird error messages:

"Expected calling “add_time()” with “11:59 PM”, “24:05” to return “12:04 AM (2 days later)”

AND

Expected calling “add_time()” with “2:59 AM”, “24:00”, “Friday” to return “12:04 AM, Friday (2 days later)”

Neither error message makes much sense. The code ought to return “0.04 AM (2 days later)” and “2:59 AM, Saturday (next day)”, respectively, which is precisely what my code does.

So, my question: Have you encountered the same issue? Is this some kind of bug or an error in the test module, or am I just being stupid? Also, what confuses me the most is that the figures in the second error message do not even correspond to the figures in the “test_two_days_later_with_day”-test in the test module, which, however, is the test that my code is allegedly failing.

Here’s the link to my code: https://repl.it/@PeterKoe/fcc-time-calculator#time_calculator.py

Any ideas?

you will need to provide a link to your code for people to be able to help

1 Like

Hi, @PeterKoe
Have you been able to detect the error?

Nope. I’ve decided to move on and do some of the other Python projects first, and then return to this issue later.

I have fixed your code

Add this line
strHourN = str(12 if hourN == 0 else hourN) + ":"

AssertionError: '0:04 AM (2 days later)' != '12:04 AM (2 days later)'
- 0:04 AM (2 days later)
? ^
+ 12:04 AM (2 days later)
? ^^
 : Expected calling "add_time()" with "11:59 PM", "24:05" to return "12:04 AM (2 days later)"

so the issue is that you return 0:04 instead of 12:04

the hour become 0 in this line:

hourN = (hourN + hourS + hourD) - (days * 24) 

Thanks for looking at my code. These issue is that I don’t think my code needs fixing. The issue is that what the test module expects the code to do makes no sense. Or am I the one who is confused here?

I’ve solved it. It was - of course - my mistake. I was confused by the whole AM/PM system, which I’m not particularly familiar with. I’m sorry to have bothered you. I guess I could have figured it out myself. Thanks anyways for your help.

I just finished this one, I had a few issues with 12/24 hour conversion as well but I got there in the end.

Your solution is more succinct than mine but if I may make I suggestion it is easier for others to read if you add some comments.

1 Like

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

You can post solutions that invite discussion (like asking how the solution works, or asking about certain parts of the solution). But please don’t just post your solution for the sake of sharing it.
If you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.