From ca4669c566e02336527ad1ab71c375f5692918af Mon Sep 17 00:00:00 2001 From: BethanyG Date: Thu, 18 Jun 2026 17:47:30 -0700 Subject: [PATCH 1/2] Added missing instruction append for raising errors. --- .../.docs/instructions.append.md | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 exercises/practice/state-of-tic-tac-toe/.docs/instructions.append.md diff --git a/exercises/practice/state-of-tic-tac-toe/.docs/instructions.append.md b/exercises/practice/state-of-tic-tac-toe/.docs/instructions.append.md new file mode 100644 index 0000000000..6b7125dd16 --- /dev/null +++ b/exercises/practice/state-of-tic-tac-toe/.docs/instructions.append.md @@ -0,0 +1,33 @@ +# Instructions append + +## Exception messages + +Sometimes it is necessary to [raise an exception][raising-exceptions]]. +When you do this, you should always include a **meaningful error message** to indicate what the source of the error is. +This makes your code more readable and helps significantly with debugging. +For situations where you know that the error source will be a certain type, you can choose to raise one of the [built in error types][error-base-classes], but should still include a meaningful message. + + +A valid game of `Tic Tac Toe` ends when one player wins. +If both players are in a winning state, or there is a mismatch between the winner and their number of moves, this exercise expects you to use the [raise statement][raise] and "throw" a `ValueError` in your solution. +Your code is also expected to throw a `ValueError` if one player is assessed as playing two turns in a row, or playing the first move when they were assigned to play the second move. + + +To raise a `ValueError` with a message, write the message as an argument to the `exception` type: + +```python +# Example when player X goes before player O. +raise ValueError("Wrong turn order: O started") + +# Example when player X goes twice. +raise ValueError("Wrong turn order: X went twice") + +# Example when player X wins AND player O wins. +raise ValueError("Impossible board: game should have ended after the game was won") +``` + +The tests will check for an exact error message match, so please read the expected results carefully. + +[raising-exceptions]: https://docs.python.org/3/tutorial/errors.html#raising-exceptions +[error-base-classes]: https://docs.python.org/3/library/exceptions.html#base-classes +[raise]: https://docs.python.org/3/reference/simple_stmts.html#the-raise-statement From a59ddfad8e7392e0c2020e7f8c9100a497a47635 Mon Sep 17 00:00:00 2001 From: BethanyG Date: Thu, 18 Jun 2026 17:51:01 -0700 Subject: [PATCH 2/2] Removed extra bracket. --- .../practice/state-of-tic-tac-toe/.docs/instructions.append.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exercises/practice/state-of-tic-tac-toe/.docs/instructions.append.md b/exercises/practice/state-of-tic-tac-toe/.docs/instructions.append.md index 6b7125dd16..3afdd19843 100644 --- a/exercises/practice/state-of-tic-tac-toe/.docs/instructions.append.md +++ b/exercises/practice/state-of-tic-tac-toe/.docs/instructions.append.md @@ -2,7 +2,7 @@ ## Exception messages -Sometimes it is necessary to [raise an exception][raising-exceptions]]. +Sometimes it is necessary to [raise an exception][raising-exceptions]. When you do this, you should always include a **meaningful error message** to indicate what the source of the error is. This makes your code more readable and helps significantly with debugging. For situations where you know that the error source will be a certain type, you can choose to raise one of the [built in error types][error-base-classes], but should still include a meaningful message.