I have the proper code but the window shows broken grid



Everything in my code is correct and codeacademy accepts my code but the grid pattern i'm getting looks like this
[['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'], ['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']]
[['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']]

HELP! lol

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


because you put print board inside the loop, you see the build up of the board

each iteration of the loop, a row is added to your board, so the first line displays the first row, then you add another row and print the board again and so on, you witness the build of your board

if you want only to print the board after its completely build, place print board outside the loop


ahh i see it now. Stupid mistake! thank you!


sorry for the double post. I pulled the print board out and re ran my code but still haven't been able to get the nice grid pattern every body is getting.

board = []
for i in range(5):
___board.append(["O"] * 5)
print board
___ denotes tab

[['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']]


this is building your board, you printing your board and printing it pretty in the next few exercises

how the data is useful for us programmers (list) and how we represent the data to the user (fancy) often doesn't match


yup i see it now putting the horse in front of the wagon again lol Thanks for your help!


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