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


#1


https://www.codecademy.com/courses/python-beginner-en-4XuFm/0/3?curriculum_id=4f89dab3d788890003000096#

Oops, try again. It looks like the rows are not represented as lists.
can you check my code?


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


#2

Hi, may be I can help.

when you append "O".. ur appending a string, the letter O.
you want to create a list for each 'reference' on the board..

Let me show you my process.. may be it helps...

you are here

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

print board

prints the following

['O', 'O', 'O', 'O', 'O']
None

Next step would be:

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

print board

prints the following

[['O'], ['O'], ['O'], ['O'], ['O']]
None

ERROR: Oops, try again. It looks like not all of your rows have 5 columns.

Final step:

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

print board

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

and its done

hope it helps in any way


#3

thanks that helps. I know what to do now.


#4

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