-2

I am trying to make a tic tac toe game and I want to have an interface where that can be changed by the user and computer's choice. For example, if I wanted to replace "2", which would be where the top middle open box would be, with "x", I could. However, I can't figure it out. Any help is appreciated.

tic_tac_screen = [["1", "2", "3"],
                 ["4", "5", "6"],
                 ["7", "8", "9"]]
tic_tac_screen.pop(1)
tic_tac_screen.insert(1, "x")
print(tic_tac_screen)
Mopps
  • 5
  • 2
  • 2
    What do you expect to be the result of `tic_tac_screen.pop(1)`? – mkrieger1 Nov 15 '21 at 20:47
  • Did you mean `tic_tac_screen[0][1] = "x"`? – mkrieger1 Nov 15 '21 at 20:48
  • @mkrieger1 Yes, I did, however when I print(tic_tac_screen) it isn't printed in rows and columns. It simply prints all in one line. How can I change? – Mopps Nov 15 '21 at 21:04
  • Does this answer your question? [printing a two dimensional array in python](https://stackoverflow.com/questions/17870612/printing-a-two-dimensional-array-in-python) – mkrieger1 Nov 15 '21 at 21:14

1 Answers1

0

You can write for example:

tic_tac_screen = [["1", "2", "3"],
                 ["4", "5", "6"],
                 ["7", "8", "9"]]
tic_tac_screen[0].insert((0), 'x')
print(tic_tac_screen)
dtroyan
  • 101
  • 1