3/19 I think my code should work, but it doesnt work


board = []

for item in range(0, 5):
grid = "O"

print board
print board
print board
print board
print board

It has 5x5 grid but it doesnt work error says:

Oops, try again.
It looks like the rows are not represented as lists.


Hello @laonfis,

You should use the preformatted text "</>" for your code so we can see how you wrote your code...

Anyway, what I think is your problem is that you didn't read the instructions, you're not supposed to print your board 5 times. It says in the instructions: "(Since we have to do this five times, it sounds like a loop might be in order.)"

Therefor your code should be completely different:

board = []

for loop in range(0,5):
   board.append(["O"] * 5) 

print board

Here we use the .append() syntax to write ["O"] 5 times instead of printing 5 times.


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


Thank you for your help. I did not put closed brackets between "O". No it works :smile:


Or, try using two for loops. The inner loop executes first, then the outer loop executes once. Then again the inner loop executes...:

board = []

for i in range(5):
    row = []
    for j in range (5):