6. Printing Pretty


I did not expect to be able to pass this level, but oddly my code gave me the green light. But since the printed result still has the ' ' in it, I was just wondering if I'm overlooking something... Thanks for your help in advanced!!!

[['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']]

<do not remove the three backticks below>
```board = []
for x in range(0,5):
    board.append(["O"] * 5)        
def print_board(board):
    for row in board: 
        print row 
print board

def print_board(board):
    for X in board:
        " ".join(board)
        print " ".join(row)


[ASSUMPTION: That we are in lesson 6: Printing Pretty as quoted as tittle of thread]

Good you got a green, but let's take it from top.

Initial code:

board = []
for i in range(5):
    def print_board(board):
        for row in board:
            print row


Inside your function, inside your for loop, use " " as the separator to .join the elements of each row.

So, all you need do is to go into the second for loop, comment out the print row statement or edit it to make use of the join method like below:

            #print row
            print " ".join(row)

I hope this helps! :wink:


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