Custom Print


My code looks like it is printing a board that is five by five but it is printing this board five times instead of one time.

board = []

for i in range(0,6):
    board.append(['O'] * 5)

def print_board(board):
    for row in board:
        print board


board contains the board, you loop should print each row


I changed board to row in the print command and obtained the correct answer. I didn't define anywhere what row is however so I am wondering how this worked.


row is your iterator, you define it in your for loop

then python will assign each item in the board list to row (in order, obviously)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.