3/19 and 4/19 don't agree?


#1
board=[]
z=["O"]*5

for i in range(0,5):
    board.append(z)

print board

this is the code i'm using in 4/19. when i submit this to 3/19 i get an error saying i have 5 references to one row, and that i should use a for loop (which im obviously using)

here's the code that ended up working for 3/19:

board=[]

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

print board

how come in 4/19 its ok to declare z outside of the loop but in 3/19 it has to be declared inside the loop even though they're the same variable? wouldn't the latter variation actually run slower (albeit almost immeasurably) because you're declaring z every time you perform the loop?


#2

Do me a favor and print your z variable out.

The data structure should print out like the following, and if not you are doing it wrong.

board = ["OOOOO"]

What you are getting is

board = ["O", "O", "O", "O", "O"]

Needless to say it is SUPER picky. I would try again to get my first example as your board.