Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def tictactoe(moves):
- for i in range(3):
- if moves[i][0] == 'X' and moves[i][1] == 'X' and moves[i][2] == 'X':
- return "'X' wins (horizontal)."
- if moves[0][i] == 'X' and moves[1][i] == 'X' and moves[2][i] == 'X':
- return "'X' wins (vertical)."
- if moves[i][0] == 'O' and moves[i][1] == 'O' and moves[i][2] == 'O':
- return "'Y' wins (horizontal)."
- if moves[0][i] == 'O' and moves[1][i] == 'O' and moves[2][i] == 'O':
- return "'O' wins (vertical)."
- if moves[0][0] == 'X' and moves[1][1] == 'X' and moves[2][2] == 'X':
- return "'X' wins (diagonal)."
- if moves[0][2] == 'X' and moves[1][1] == 'X' and moves[2][0] == 'X':
- return "'X' wins (diagonal)."
- if moves[0][0] == 'O' and moves[1][1] == 'O' and moves[2][2] == 'O':
- return "'O' wins (diagonal)."
- if moves[0][2] == 'O' and moves[1][1] == 'O' and moves[2][0] == 'O':
- return "'O' wins (diagonal)."
- isempty = 0
- for row in range(3):
- for item in range(3):
- if moves[row][item] == ' ':
- isempty = isempty + 1
- print isempty
- if isempty == 0:
- return 'Draw.'
- return ''
Advertisement
Add Comment
Please, Sign In to add comment