From 240e216c51d90be86e62cf8c00a7674b755a32b7 Mon Sep 17 00:00:00 2001 From: Satwik Kansal Date: Mon, 26 Feb 2018 00:03:37 +0530 Subject: [PATCH] Update explanation: Tic tac toe Fixes https://github.com/satwikkansal/wtfpython/issues/68 --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 35a7c02..b9b40ee 100644 --- a/README.md +++ b/README.md @@ -502,6 +502,15 @@ And when the `board` is initialized by multiplying the `row`, this is what happe ![image](/images/tic-tac-toe/after_board_initialized.png) +We can avoid this scenario here by not using `row` variable to generate `board`. (Asked in [this](https://github.com/satwikkansal/wtfpython/issues/68) issue). + +```py +>>> board = [(['']*3)*3] # board = = [['']*3 for _ in range(3)] +>>> board[0][0] = "X" +>>> board +[['X', '', ''], ['', '', ''], ['', '', '']] +``` + --- ### ▶ The sticky output function