I need some help with my Time Calculator code. This is my very first challenge and I cannot pass all 12 tests. I was trying to switch the 12 hr format to 24 format for calculation but it seems not working. I cannot figure it out.
Can anyone help to have a look at it and give me some advice??
Yes, returning is now good and we got some actual errors.
But first, no idea what you are trying to post it’s just a large blank space…
Anyway going back to your project and running it, the errors are… massive, to say the least?
Just take a moment and look at the assertion error - is posting your result first, then the expected:
'Expected calling "add_time()" with "11:55 AM", "3:12" to return "3:07 PM"')
AssertionError: 'Returns: 00:52 PM (8 days later)' != '3:07 PM'
You return ‘00:52 PM (8 days later)’ instead of the expected ‘3:07 PM’ → so apart from PM, there is not a single number correct.
Or this one:
self.assertEqual(actual, expected, 'Expected calling "add_time()" with "8:16 PM", "466:02" to return "6:18 AM (20 days later)"')
AssertionError: 'Returns: 08:42 PM (353 days later)' != '6:18 AM (20 days later)'
Your days are off by over 15 times the expected value.
So now that we can see the errors, take a moment to figure out how to read them and then you have to REALLY think about what math you are doing.
hm… I’d recommend you either look at the part supposed to do that and try to figure out why it doesn’t - or why another part is undoing it. OR you just add a condition at the end turning a 0 to a 12.
As for the other errors, it seems like you add the “days later” string in situations where it’s not needed. So the logic for time-changes must be off.