How to print each row array? (5. Custom Print)


#1



https://www.codecademy.com/courses/python-beginner-en-4XuFm/0/5?curriculum_id=4f89dab3d788890003000096#
Instructions: 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.


Error: Oops, try again. Your code threw the following error: list indices must be integers, not tuple


board = []
for x in range(0,5):
    board.append (["O"] * 5 )
    
def print_board(board): 
    for row in board:
        for column in board:
            print board[row, column]
            
print_board(board)


#2

Try printing step by step and see what happens..

if you still can't manage to solve it call for help again :slight_smile:


#3

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