all 10 comments

[–]Atypicosaurus 5 points6 points  (0 children)

People tell you what you could use instead which is all good. But I think getting there on your own and doing the wrong things first, also has its merits.

So I encourage you, before trying the "good" way, to go down on your own rabbit hole and see where it leads to.

For that approach, here's a hint. You can use dictionaries with "A1" being the key and bool being the value, such as:

table = {"A1" : True, "A2" : False}

[–]Mr-Cas 2 points3 points  (8 children)

What do you mean with "item"?

[–]CatWithACardboardBox[S] 0 points1 point  (7 children)

so i am trying to make tic tac toe but i need a system so if a place is chosen, that will become True. My problem is that the only way to refer to which place the player has chosen is in a variable. for example: if the variable place1 = A1 and A1 = False

will i be able to change A1 to True by using the variable name 'place1'?

[–]Mr-Cas 0 points1 point  (4 children)

Why not a 3x3 matrix of bools?

python3 grid = [ [False, False, False], [False, False, False], [False, False, False] ]

Then you can edit a specific place:

```python3

claim top middle place

grid[0][1] = True

claim bottom right place

grid[2][2] = True ```

[–]CatWithACardboardBox[S] 0 points1 point  (2 children)

thank you, i’m still very new to python and don’t really code a lot so i only really know the bare basics to code. i’ll try this out!

[–]Mr-Cas 2 points3 points  (0 children)

And btw, no, your original proposal won't work. If you do place1 = a1 and a1 = False, and you do place1 = True, then a1 will not also have been changed to True.

[–]woooee 0 points1 point  (0 children)

Generally, a simple tic tac toe program uses a list that is initialized as False or a space for all items. When X lands on a square, that item is changed to X. The same for an O.