Skip to main content
8 events
when toggle format what by license comment
Apr 23, 2023 at 0:04 comment added Salome Naskidashvili This last comment saved my time which I would have wasted just because everything was correct and I couldn't figure out why it was returning 1. Thanks!
Sep 26, 2022 at 17:53 comment added KptKrunch I figured this out. It's a bit misleading. Your fuel.py code is irrelevant and it doesn't matter (though you still want pytest to pass it it). It's what they are looking for. Only ONE assert for the check_convert function. "3/4" == 75 is just fine. Once you introduce more asserts to test, it fails with exit code 1. I used separate functions for gauge (obv) , zero error, and str error, and it comes back 100%!
Jun 15, 2022 at 21:52 history edited kcw78 CC BY-SA 4.0
fixed small typos
Jun 15, 2022 at 17:19 comment added Anonymous coward If anyone else comes across this, follow the pytest documentation for checking for exceptions. docs.pytest.org/en/latest/how-to/…
May 26, 2022 at 17:30 history edited kcw78 CC BY-SA 4.0
fixed link to 2nd answer
May 26, 2022 at 12:33 comment added kcw78 The code in my answer does not return None. The bare raise statement re-raises the exception from the try/except. So if your statement was x = 1./0., it would throw a ZeroDivisionError exception, pass it to the except block which will raise that exception back to the calling program. Try it and see. (FYI, I am also doing CS50 for Python, so have done these psets.)
May 26, 2022 at 6:56 comment added TimL thanks for the suggestions. I previously had the correct error message printed for each type of errors (e.g. TypeError, print("Enter a fraction with two integer"), but the CS50 problem requires us not to do any print statement, but rather re-prompt the user for an input if what they either didn't meet the input specifications. I also am aware by default, it'll return "None" if the exception is not specified, I explicitly returned "None" as I'll need some action under "exceptions", I guess another alternative is to use "pass". Will keep digging for a fix. Thanks.
May 25, 2022 at 22:35 history answered kcw78 CC BY-SA 4.0