What is wrong with my code? 6.printing pretty


#1



Im unsure what is wrong with this code? It gets the correct awnser but it says it is incorrect??


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

`


#2

By writing a reference to this in every cell of your list, they will all be the same. Instead of twenty-five unique cells, there are 25 of the one. Change one and you change all. Plus, leave out the space and insert it with the .join() statement.

board = []

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

and,

for i in range(len(board)):
    print " ".join(board(i))

#3

ok thank you very much, that makes sense now :grinning:


#4

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