It might also help to see the actual output you get when you run the various test cases for your function. You can take a look at what the tests do by opening the file w2_unittests.py. The tests should tell you which one failed, which is part of what we can hope to learn by looking at the output.
I have yet to solve my problem. I do not understand w2_unittests.py. I opened it but did not know how to solve the problem.
The exercise strikes me. I followed the examples in Section 4.2 and am still getting three passes and one failed. I understand the code to fill in the missing values, but I am not getting the output. Please, I need help.
Ok, your code clearly wrong, since you get the wrong answer. Now the question is how to figure out why it is wrong. As Tom pointed out, they gave you detailed step by step example in the instructions. My recommendation would be to “instrument” your code with print statements, so that you can track the steps and compare to their example and figure out where you are “going off the rails”.
As an example, I instrumented my code with print statements and here’s my output for that same test with all the intermediate prints:
So the first M value there is the original input for the test case. And you can see that my final answer agrees with the “Expected” value shown in your failure message.
Notice that you don’t even end up with 0s in position [1,0] and [2,0] of the output matrix. So the basic inner loop is not working correctly. Now you need to figure out why.
Yes, but the point is that is just with one particular test matrix. Then what happens if they give you a different test input that has 4 or 5 rows?
You’ve hard-coded the loop limit to be 2, but the point is to use the variable that has the actual number of rows, right? It may be different in each invocation of your function, which is why “hard-coding” is a bad idea.
Footnote for other readers: some of the discussion here is based on a DM thread in which we actually looked at the code, which we can’t really do here in the public thread.