why is coding tic-tac-toe so hard

I wrote it in one line of code:

ChatGPT> create a game of tic tac toe in pyth

Output:

```py

def print_board(board):

print("-------------")

for i in range(3):

print("|", end=" ")

for j in range(3):

print(board[i][j], "|", end=" ")

print()

print("-------------")

def check_win(board, player):

# check rows

for i in range(3):

if board[i][0] == player and board[i][1] == player and board[i][2] == player:

return True

# check columns

for j in range(3):

if board[0][j] == player and board[1][j] == player and board[2][j] == player:

return True

# check diagonals

if board[0][0] == player and board[1][1] == player and board[2][2] == player:

return True

if board[0][2] == player and board[1][1] == player and board[2][0] == player:

return True

return False

def tic_tac_toe():

# initialize the board

board = [[" ", " ", " "], [" ", " ", " "], [" ", " ", " "]]

# initialize the players

players = ["X", "O"]

# initialize the current player

current_player = players[0]

# initialize the number of turns

turns = 0

# loop until the game is over

while True:

# print the board

print_board(board)

# get the current player's move

print("It's", current_player, "'s turn.")

row = int(input("Enter the row number (0-2): "))

col = int(input("Enter the column number (0-2): "))

# check if the move is valid

if board[row][col] != " ":

print("That space is already taken. Try again.")

continue

# update the board with the current player's move

board[row][col] = current_player

# check if the current player has won

if check_win(board, current_player):

print_board(board)

print(current_player, "wins!")

break

# check if the game is a tie

turns += 1

if turns == 9:

print_board(board)

print("It's a tie!")

break

# switch to the other player

current_player = players[(players.index(current_player) + 1) % 2]

# play the game

tic_tac_toe()

```

/r/ProgrammerHumor Thread Link - i.redd.it