Printing Pretty


#1

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

print board

itCode returns this . And it passed
[['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']]

however i thought it was going to return "O O O O O O "
is it still right or why is it passing


#2

I think those prints are unnecesary, or I'm not understanding what you were trying to do.

You created a function called print_board and you send a board to it (as a parameter), the function itself is the one in charge of doing the printing. So you should call this function and not print the board:
print_board(board)


#3

thanks. the instructions said it would return " O O O O O " but it didnt and still passed which is why i was confused.


#4

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