3. Make a list


#1



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


Oops, try again. It looks like board is not a list.

I'm struggling to see how i can use the for loop and range() to repeat ["O"] * 5)


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


#2

for i in range(0,5): # this should be from 0 to length of the list. you do not have to type out 1 ,2 3,4 since the length
is already 5
board.append(["O"] * 5) # this should add the rows to board = []

Hope this helped.


#3

I've changed the code to this

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

The error
Oops, try again. It looks like board is not a list

I'm unsure why my board isn't a list, any help will be appreciated. :laughing:


#7

This is how the code looks like, from my experience I see board.append() indented..


#8

Any ideas on what needs to be done :grin:

I have changed the post on top to update what's going on ..


#9


#10

Can you explain how the I in range(0, 5) line works?


#11

It is a simple for loop.It repeats whatever code under it for given range.
range(0,5) means number of time for loop is executed. We have given (0,5) here 5 is excluded so loop is executed for 5 times(i.e from i=0 to i=4)
board.append([“O”]*5) generates five O s.


#12

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