5. Custom Print


Please, help:


First, delete your existing print statement.
Then, define a function named print_board with a single argument, board.
Inside the function, write a for loop to iterates through each row in board and print it to the screen.
Call your function with board to make sure it works.


Traceback (most recent call last):
File "python", line 14, in
File "python", line 12, in print_board
TypeError: list indices must be integers, not list

board = []


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

def print_board(board):
for i in board:
for w in i:
print board[i][w]



so far i can tell from the instructions, you need a single loop, i don't see anything about a second loop? then the iterator contains the rows, which you can just print, no need to something with square brackets


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