6/19 Printing pretty


#1

Why do I get a 5x15 board with this code?

O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O

board = []
for i in range(5):
    board.append(["O"] * 5)
    def print_board(board):
        for row in board:
            print " ".join(row)
    print_board(board)

#2

We converting our list into a string using join() method, when we use print, It just cuts off (It does this with string) the quotes and its look like this (at each iteration).


#3

you nested the print_board inside the loop, so the board will be printed 5 times


#4

Thank you so much for the help!


#5

thanks for sharing.