{"record":{"id":"d9559dd0c0958afd","repo":"TheAlgorithms/Python","slug":"row-must-be-equal-in-length-to-the-other-rows-in-t","errorCode":null,"errorMessage":"Row must be equal in length to the other rows in the matrix","messagePattern":"Row must be equal in length to the other rows in the matrix","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"matrix/matrix_class.py","lineNumber":257,"sourceCode":"            + \"\\n \".join(\n                [\n                    \"[\" + \". \".join([str(value) for value in row]) + \".]\"\n                    for row in self.rows\n                ]\n            )\n            + \"]\"\n        )\n\n    # MATRIX MANIPULATION\n    def add_row(self, row: list[int], position: int | None = None) -> None:\n        type_error = TypeError(\"Row must be a list containing all ints and/or floats\")\n        if not isinstance(row, list):\n            raise type_error\n        for value in row:\n            if not isinstance(value, (int, float)):\n                raise type_error\n        if len(row) != self.num_columns:\n            raise ValueError(\n                \"Row must be equal in length to the other rows in the matrix\"\n            )\n        if position is None:\n            self.rows.append(row)\n        else:\n            self.rows = [*self.rows[0:position], row, *self.rows[position:]]\n\n    def add_column(self, column: list[int], position: int | None = None) -> None:\n        type_error = TypeError(\n            \"Column must be a list containing all ints and/or floats\"\n        )\n        if not isinstance(column, list):\n            raise type_error\n        for value in column:\n            if not isinstance(value, (int, float)):\n                raise type_error\n        if len(column) != self.num_rows:\n            raise ValueError(","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/matrix/matrix_class.py#L239-L275","documentation":"Error \"Row must be equal in length to the other rows in the matrix\" thrown in TheAlgorithms/Python.","triggerScenarios":"Thrown at matrix/matrix_class.py:257 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set the row to the same length as the existing rows of the matrix."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f5988cc09713315817df6a7e327e258013a94440","analyzedAt":"2026-08-14T17:30:07.041Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}