Printing Pretty Help me out of this................![solved] by #stetim94 in #post1


#1



https://www.codecademy.com/courses/python-beginner-en-4XuFm/0/6?curriculum_id=4f89dab3d788890003000096


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

#2

this line:

print "  ".join(row)

there should be one space between the quotation marks ("), not two


#3

Also better way to write:

        return " ".join(row)

  print(print_board(board))

So you returning to the function and printing the function output. It is a good practice :slight_smile:


#4

except the whole purpose of the function is to print the board, and you will need it later, plus then it is better to use print. And, using return means only one row is printed, instead of all 5.

there are scenarios (like this one) where print simply is better then return


#5

Yes you are right, especially this exercise does not finish until the last stage, so it is not finished yet and the whole game has lots of printing.


#6

yes, which is why you have this function to do al the printing for you