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.
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
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.
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.