I'm currently coding a Sudoku clone but I'm having trouble displaying the
board: # Sudoku
# Sudoku is a logic-based number-placement puzzle
# The objective is to fill a 9×9 grid with digits so that each column, each
row, and each of the nine 3×3 sub-grids that compose the grid contains all of
the digits from 1 to 9import randomdef new_board():
"""Creates the game board. """
board=[]
for i in range(9):
column=[]
for j in range(9):
column.append(i)
board.append(column)
return boarddef display_board(board):
"""Display game board on screen."""
for i in range(9):
for j in range(9):
rand_num=random.randint(0,9)
if rand_num not in board[i]:
board[i][j]=rand_num
else:
board[i][j]=' '
print(board[i][j],"|")# assign the new board to a variable and
display it on the screen
game_board=new_board()
display_board(game_board)
I cant think of a way to get each column in the for loop (board[i]) to print
side by side. Any help would be much appreciated. Myles.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor