Custom Print


Hi everyone, could someone please help me understand how the code works in this exercise? I was able to put it together, given the instructions, but I am simply not quite sure why is it working the way it is.

Given, "for x in range(0,5):" means for x in 0 append...for x in 1 append, etc. I would expect that the def print_board would print out output for character.

Replace this line with your code. 
board = []                 # empty list

for x in range(0,5):    #for each x is in range of 5, add "O"*5 to board

def print_board(board): #take the for cycle above
    for y in board:      #for each y in the above cycle print y
        print y
print_board(board)    #print board


no, it doesn't, see what happens if you do this:

print board

you can see your multi dimensional list, by looping over it, you only access the first list, not the one nested inside


Ok, got it. Thank you!