[Tutor] help with tic-tac-toe program

Andrew McReynolds amcreynolds3 at yahoo.com
Sun Nov 16 19:52:30 CET 2014

The section of the assignment that I'm working on states: 2) Write a function called loadGameBoard (player_marks) where player_marks is a dictionary that contains the players’ marks. This function creates a 3x3 array with the players’ marks populated in the correct row/column indices using the formula 3*row+column. This function returns the 3x3 array. You must use a loop at least once.3) Write a function called printGameBoard (gameBoard) where gameBoard is a 3x3 array that contains the players’ marks. This function draws the game board and returns None. You must use a loop at least once in this function or in a function that this function calls.An example is if gameBoardArray[0][1] has ‘X’ and gameBoardArray[1][1] has ‘O’, this function shoulddraw the game board like:----------------| | X | | ----------------| | O | | ----------------| | | | ----------------"
What I have so far is:
def loadGameBoard (player_marks):      null= " "           board= [[null,null,null],[null,null,null],[null,null,null]]      for row in range(3):            for column in range (3):                  position = 3*row+column                  if position in player_marks["X"]:                     board[row][column]="X"                  if position in player_marks["O"]:                     board[row][column]="O"                           return (board)
def printGameBoard(gameBoard):      board=(("-"*8,("| ")*4))*3      #for line in board:                  return ()
Any advice for continuing? 
Thanks in advance for assistance,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20141116/cca93ba5/attachment.html>

More information about the Tutor mailing list