Tic-Tac-Toe Result
Programs with input · Advanced · about 18 min
Read a tic-tac-toe board as three lines of three characters each: X, O, or - for an empty square. Print one of these:
X winsorO winsif that player has three in a row, across, down or corner to cornerDrawif every square is filled and nobody has wonNot finishedif there are empty squares and nobody has won
No board has two winners.
The prompts inside input() are not checked, only what you print.
Examples
You type:
XXX OO- ---
The program prints:
X wins
You type:
XOX XOO OXX
The program prints:
Drawrow1 = input("Row 1: ")
# Read the other two rows, then print the result
The solution opens after your first Check.