{"record":{"id":"1847c75686ed2e8e","repo":"TheAlgorithms/Python","slug":"matrix-rows-can-only-contain-letters-and-numbers","errorCode":null,"errorMessage":"Matrix rows can only contain letters and numbers.","messagePattern":"Matrix rows can only contain letters and numbers\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"matrix/matrix_based_game.py","lineNumber":89,"sourceCode":"    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]]:\n    \"\"\"\n    >>> parse_moves(\"0 1, 1 1\")","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/TheAlgorithms/Python/blob/f5988cc09713315817df6a7e327e258013a94440/matrix/matrix_based_game.py#L71-L107","documentation":"Error \"Matrix rows can only contain letters and numbers.\" thrown in TheAlgorithms/Python.","triggerScenarios":"Thrown at matrix/matrix_based_game.py:89 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use only alphanumeric characters in matrix rows."],"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"}