6/19 Printing Pretty


#1

This seemed to work for me but I don't understand why? Here are two options:

Option 1:

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

Option 2:

board = []
for i in range(5):
    board.append(["O"] * 5)
def print_board(board):   
    for lst in range(0,len(board)):
        print "---".join(board(lst))

As you can see I put dashes in the second option and it still passed, maybe this input means null?
I also didn't get a grid when finished, it just output to the console "none."


#2

This is what I did and it worked!

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


#3

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


#4

I struggled for a bit and then realised it wasn't working because i was using a "0" instead of an "O".

See below what worked for me:

board = []

for x in range(5):
board.append(["O"]*5)

def print_board(board):
for row in board[0]:
print " ".join(board[0])

print_board(board)