{"record":{"id":"a5ed87c633f81185","repo":"TheAlgorithms/Python","slug":"each-row-in-the-matrix-must-have-exactly-size-ch","errorCode":null,"errorMessage":"Each row in the matrix must have exactly {size} characters.","messagePattern":"Each row in the matrix must have exactly (.+?) characters\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"matrix/matrix_based_game.py","lineNumber":87,"sourceCode":"    Traceback (most recent call last):\n        ...\n    ValueError: The matrix dont match with size.\n    >>> validate_matrix_content(['aa%', 'aaa', 'aaa'], 3)\n    Traceback (most recent call last):\n        ...\n    ValueError: Matrix rows can only contain letters and numbers.\n    >>> validate_matrix_content(['aaa', 'aaa', 'aaaa'], 3)\n    Traceback (most recent call last):\n        ...\n    ValueError: Each row in the matrix must have exactly 3 characters.\n    \"\"\"\n    print(matrix)\n    if len(matrix) != size:\n        raise ValueError(\"The matrix dont match with size.\")\n    for row in matrix:\n        if len(row) != size:\n            msg = f\"Each row in the matrix must have exactly {size} characters.\"\n            raise ValueError(msg)\n        if not all(char.isalnum() for char in row):\n            raise ValueError(\"Matrix rows can only contain letters and numbers.\")\n\n\ndef validate_moves(moves: list[tuple[int, int]], size: int) -> None:\n    \"\"\"\n    >>> validate_moves([(1, 2), (-1, 0)], 3)\n    Traceback (most recent call last):\n        ...\n    ValueError: Move is out of bounds for a matrix.\n    \"\"\"\n    for move in moves:\n        x, y = move\n        if not (0 <= x < size and 0 <= y < size):\n            raise ValueError(\"Move is out of bounds for a matrix.\")\n\n\ndef parse_moves(input_str: str) -> list[tuple[int, int]]:","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/matrix/matrix_based_game.py#L69-L105","documentation":"Error \"Each row in the matrix must have exactly {size} characters.\" thrown in TheAlgorithms/Python.","triggerScenarios":"Thrown at matrix/matrix_based_game.py:87 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Make every row string exactly 'size' characters long."],"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-15T22:17:37.221Z"}