Printing Pretty


#1


I want to be sure that I understand this bit of the code:

print " ".join(row)

so the .join part removes the [ and " from the code. and the " " part will put the spaces in between the O's
am I correct?


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


#2

Yes you understand what your code is doing explicitly.

The method join() returns a string in which the string elements of sequence have been joined by str separator. :grin:


#3

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