Python Project X-O Game
Python Project X-O Game
Class: XI-A
Project title:
x/o game
1. **Board Representation:**
- The sport board is represented as a 3x3 matrix initialized with empty spaces
(' ') the usage of a nested list.
6. **End of Game:**
- If a participant wins, the winning board is displayed, and the winner is
announced.
- If the board is complete and there's no winner, the sport proclaims a draw.
7. **Main Block:**
- The recreation is commenced by calling `tic_tac_toe` if the script is
administered directly (now not imported as a module).
Python code:
def print_board(board):
print(" | ".join(row))
print("-" * 5)
for i in range(3):
return True
return True
return False
def is_board_full(board):
def tic_tac_toe():
current_player = 'X'
while True:
print_board(board)
if check_winner(board, current_player):
print_board(board)
break
elif is_board_full(board):
print_board(board)
print("It's a draw!")
break
else:
if __name__ == "__main__":
tic_tac_toe()
Output :