Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lines = [input().split() for _ in range(3)]
- first_player_win = None
- for player in ['1', '2']:
- if (any(all(cell == player for cell in line) for line in lines)
- or any(all(line[i] == player for line in lines) for i in range(3))):
- first_player_win = (player == '1')
- break
- # Check diagonals for both players
- for player in ['1', '2']:
- if (all(lines[i][i] == player for i in range(3))
- or all(lines[i][2 - i] == player for i in range(3))):
- first_player_win = (player == '1')
- break
- if first_player_win is None:
- print("Draw!")
- elif first_player_win:
- print("First player won")
- else:
- print("Second player won")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement