Home / Expert Answers / Computer Science / based-on-a-text-file-that-resembles-a-tic-tac-toe-board-xxx-oox-oox-nbsp-please-complete-the-pa876

(Solved): Based on a text file that resembles a tic tac toe board: XXX OOX OOX   Please complete the ...



Based on a text file that resembles a tic tac toe board:

XXX

OOX

OOX

 

Please complete the rest of this program:

boardfile = open("tictactoe_board.txt")
board = boardfile.read()
boardfile.close()

rows = board.split('\n')

print(rows)

 

A. Add to or modify the code I've given you so that it prints an error message if the number of rows is not exactly 3.

B. Make it so that an error message is printed if the number of columns is not exactly 3. (i.e. if any row has fewer or more than 3 characters).

C. Make it so that a message is printed if any of the rows is three-in-a-row (either X or O).

[Extra Credit] Make it so that a message is printed if there is three in a row horizontally, vertically, or diagonally.



We have an Answer from Expert

View Expert Answer

Expert Answer


A) Add to or modify the code I've given you so that it prints an error message if the number of rows is not exactly 3. boardfile = open("tictactoe_boa
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe