1
0
mirror of https://github.com/satwikkansal/wtfpython synced 2024-11-22 11:04:25 +01:00

Update explanation: Tic tac toe

Fixes https://github.com/satwikkansal/wtfpython/issues/68
This commit is contained in:
Satwik Kansal 2018-02-26 00:03:37 +05:30
parent a0100a8b48
commit 240e216c51

9
README.md vendored
View File

@ -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) ![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 ### ▶ The sticky output function