Apr-15-2018, 10:06 AM
new_row1 = [' ', '|', ' ', '|', ' '] new_row2 = [' ', '|', ' ', '|', ' '] new_row3 = [' ', '|', ' ', '|', ' '] def displayBoard(row1, row2, row3, playerMarker, comMarker, whoseTurn, move): rowChoice = {7: row1[0], 8: row1[2], 9: row1[4], 4: row2[0], 5: row2[2], 6: row2[4], 1: row3[0], 2: row3[2], 3: row3[4], 10: row1[1]} if whoseTurn == 1: #1 for player, 0 for computer rowChoice[move] = playerMarker #say playerMarker = 'X' print ("rowChoice[move] is ", rowChoice[move]) #for checking whoseTurn -= 1 elif whoseTurn == 0: rowChoice[move] = comMarker print ("Com's turn") whoseTurn += 1 print (''.join(row1)) print ("-+-+-") print (''.join(row2)) print ("-+-+-") print (''.join(row3)) return row1, row2, row3, whoseTurn row1, row2, row3, playerTurn = displayBoard (new_row1, new_row2, new_row3, playerMarker, comMarker, playerTurn, move)Hi guys,
Am trying to put the lists row1 as the values of a dictionary rowChoice,
for example playerMarker is 'X' and move is '7', am trying to pass the value of playerMarker -> rowChoice[7] (rowChoice[move]) -> row1[0] -> row1.
I am able to assign rowChoice[7] the value, but not row1[0] and row1. Please assist. Thanks