Unable to print rows


#1



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


Error message: "It looks like the rows are not represented as lists."


How to print rows ?


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


#2

this exercise is not about printing rows? Its about building your game board.

your row:

"O"*5

seems to be a string, it should be a list


#3

Instructions say to use the way they have printed the lists. We have to make a list of rows. How to do that using this method?


#4

the print purely shows how to create a list. You have to append the row to board, not print it


#5

How to do that? This is what it says: "Inside the loop, .append() a list containing 5 "O"s to board, just like in the example above"


#6

what you did:

you appended a string containing 5 "O"'s to board.

string != list. Append a list, not a string


#7

yes. so is this the correct way?

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

it gives an error message: it looks like not all of your columns have 5 Os.


#8

from the example:

print ["O"] * 5

will print out ['O', 'O', 'O', 'O', 'O']

does ["O,O,O,O,O"] look at the same to you as ['O', 'O', 'O', 'O', 'O']?


#9

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