3/19


#1

board = []
for item in range(5):
board.append("O" * 5)
print board
When i try this code what happens is this
['OOOOO']
['OOOOO', 'OOOOO']
['OOOOO', 'OOOOO', 'OOOOO']
['OOOOO', 'OOOOO', 'OOOOO', 'OOOOO']
['OOOOO', 'OOOOO', 'OOOOO', 'OOOOO', 'OOOOO']
None
I understand why it does this but i do not know how to make it only print the list once on each line. could anyone help.
FYI if the print board is on the outside of the loop this happens
['OOOOO', 'OOOOO', 'OOOOO', 'OOOOO', 'OOOOO']
None
I was hoping someone could help with the issue


#2

try

board.append(["O"] * 5)

i.e.

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

#3

thanks rydan it is working now


#5

This doesn't print the five "O"'s on 5 separate lines. I don't understand how this accomplishes what we were asked to accomplish.


#6

That's a fair question! The early parts of this section build VERY slowly. The goal of this lesson is just to print the list 'board' unformatted. Later sections work through the formatting requirements.

If you read the title; Making a List; you can see that we've made and printed the list. It's quite a baby step though. You'll likely breeze through the next couple of lessons as well, as none of them are much more complex.

I think it was done this way to focus on each change separately. That way you've got a clear understanding of what you're accomplishing, even though each step seems so small.


#7

This lesson is bullpoopy.

board = ["O","O","O","O","O"]
for x in range(5):
print board

this code fails the lesson but accomplishes what is asks for.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
board = []
for x in range(5):
board.append(["O"]*5)
print board

This code passes the lesson but does not print what the lesson asks for