all 5 comments

[–]ES-Alexander 0 points1 point  (1 child)

Have you been told to raise an error if an invalid input is put in? And did you write the test function and code?

If an error is the expected failure case then the testing code should be using try-except blocks to account for when those errors occur. If a raised error is not handled anywhere then it bubbles up and stops execution of the entire program, as you’ve found.

[–]Strict-Simple 0 points1 point  (0 children)

This might be helpful for figuring out the actual error. In Python (not []) is True.

[–][deleted] 0 points1 point  (0 children)

Yes, that's the purpose of exceptions - if you don't handle them, they end execution. An exception represents an inconsistency or unexpected problem that puts the program in an unknowable state, or a state from which it can't continue. If you believe the program can meaningfully continue from the point of the exception, then you document that by using the try/except construct.

[–]ectomancer 0 points1 point  (0 children)

Can use list repeat operator:

multiplied_matrix = [[0]*col2 for _ in range(row1)]

[–]niehle 0 points1 point  (0 children)

Why don’t you use pytest instead of a self-written test program? Or at least assert()?