i'm a beginner,.. please help!
here is the question.
Download the TICTACTOE program. Complete it by writing the cellOpen and the winnerCheck functions. This does not require any changes to the rest of the program. Modify the program so that the two players enter their names (no validation is needed) and the program prompts them using their name, rather than X and O. Suggestion: use a list of strings for the player names.
1.the game never ends, unless it's a tie. (there is no winner.)
The "winnerCheck" function needs to be completed.
2.even if a cell is occupied, it's allowed to overwrite.
The "cellOpen" function needs to be completed.
3.i have to let two players to enter their names and the program prompts them using their names, rather than x and o.
def display(board): print('|' + '-' * 17 + '|') for row in board: print('| %c | %c | % c |' % (row, row, row)) print('|' + '-' * 17 + '|') def winnerCheck(board): return False def cellOpen(cell, board): return True def validChoice(cell): if(not cell in '012345678') or (len(cell) != 1): print('Entry must be in range 0..8.') return False return True def getChoice(player, board): print('%s: it is your turn.' % player) entryOK = False while not entryOK: cell = input('Enter a number - 0..8: ') if validChoice(cell) and cellOpen(cell,board): entryOK =True else: cell = input('Enter again: ') return cell def playGame(board): playermarks = 'XO' round = 0 winner = False while round < 9 and not winner: mark = playermarks[round % 2] cell = int(getChoice(mark, board)) board[cell // 3][cell % 3] = mark display(board) winner = winnerCheck(board) round = round + 1 if winner: return mark else: return 'T' def gameDoneMessage(result): if result in 'XO': print('Congratulations %s. You are the winner!' % result) else: print('The game ended in a tie!') def main(): board = [['0', '1', '2'], ['3', '4', '5'], ['6', '7', '8']] display(board) gameResult = playGame(board) gameDoneMessage(gameResult) main()