# Having difficulty in graded assignment of Back substitution

Respected sir,
This is in reference to the graded assignment for week 2 that was shared with us and I have solemnly tried to derive a satisfactory solution but am unable to do the same.
In the second exercise for (back substitution) I am unable to figure out the final index that would be required. [As in when we replace the updated row in the matrix]. I don’t know what is to be added finally… as in do we take the matrix square bracket substituted row equal to matrix square bracket row to be reduced? I cannot understand anything in fact I have started losing out on the entire algorithm of the program now.

So far after running this program I was able to pass 1 test but the remaining was showing as failed which I get as the output do not match but what to do?
So far only the last step (where the updated row needs to be added) shows significant changes in output once I make any change in it. So I believe that it is the only step that requires amendment.

Sorry sir for disturbing you.
Thank you for your hard work.

# Replace the updated row in the matrix, be careful with indexing!

``````        M[j,:-2] = M[index,:-2]
``````

This is what I am doing right now. Just in case it may help with coming up with a solution( I am afraid it is not permitted to share the entire code so only sharing a small part)

The key point when writing code is that first you need to have a very clear picture in your mind of what the code needs to do. Then you need to translate those mathematical steps into python code.

So my suggestion is to take the test case that fails and first work it out with pencil and paper following the detailed explanation in the instructions. Now you’ve got a clear picture of what your code needs to do. Then put print statements in your code so that you can actually see the steps that your code is taking. At what point do things differ from what you know should be happening.

I don’t see any steps in that which would require touching a row, but leaving out the last 2 elements of that row. That’s what M[j,:-2] means, right?

If you got the `row_echelon_form` function correct, I’d say that is much more complex than `back_substitution`. Just read through their explanation for that function again and I bet it becomes clear to you what to do in the code. In every case, you are handling the whole row and not leaving out any elements of it.

If after doing that you still feel stuck, then please show us the output you are getting from the failing test case. Not the code, please, but just all the output up to and including the error message.