Make a List (incomplete)


Here is my code:

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

Why does it only show one row of "O"s?


because you print only one row

What do you want to print? You will work further on printing your board later


Well, I believe according to the instructions I am to make a 5X5 grid of "O"s.
Or do I literally have to repeat my code 5 times?
If so, is there and easier way?


i would personally move forward, you will work on printing your board.

if you want to print each row, place print board[i] inside the for loop

if you just want to print the board, do print board after the for loop


Ok, thanks, now this is my modified code a couple stages on:

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

def print_board(board):
    for row in board:
        print row
print board

But the console is showing this:

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

Which I don't believe it is suppose to do, rather it is suppose to create the 5X5 grid.


there is a difference between how the data looks under the hood vs how you display it to the user.

currently, you simply print board. your print row doesn't do anything given function need to be called in order to execute


Ah okay. Thanks a lot. :slight_smile:


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