I'm making a tic tac toe game in python and I have all of the actual game play functions working properly but I can't get the game board to print correctly.
game = [[' ',' ',' '],[' ',' ',' '],[' ',' ',' ']]
for row in game:
print(' |'*(len(game)-1)+' ')
for space in row:
print(' '+space+' |',end='')
print('\n'+' |'*(len(game)-1)+' ')
if game.index(row) < len(game)-1:
print('----'+('----'*(len(game)-2))+'---')
for some reason the row index isn't incrimenting unless there's a move in each row. When the game begins empty the output is:
| |
| | |
| |
-----------
| |
| | |
| |
-----------
| |
| | |
| |
-----------
There shouldn't be a line along the bottom but it goes away when there's a move in each row. I'm also trying to get rid of the ' |'in the middle of each space on the right. Any tips or suggestions would be greatly appreciated!