13.3 Make a list


#1

Hi guys,

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


Error message: "It looks like not all of your rows have 5 columns".


Approve and go to the next task


board = []

for bo in range (5):    
    board.append(['O' * 5])
    
def print_board(board):
    for row in board:
        print("".join(row))
        
print(print_board(board))


#2

What is my mistake? I see 5 columns x 5 rows in console.


#3

your board should like 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']]

your rows are just strings, how are we ever going to update the board then? That becomes really difficult


#4

Definitely no. I see on the console

OOOOO
OOOOO
OOOOO
OOOOO
OOOOO
None
None

and form my point of view it is exactly 5 x 5 board. I do not understand why the program does not accept it


#5

hmmm let me think how to update


#6

look at your raw board:

board = []

for bo in range (5):    
    board.append(['O' * 5])
    
print board

it will show:

[['OOOOO'], ['OOOOO'], ['OOOOO'], ['OOOOO'], ['OOOOO']]

which makes updating the board really difficult, so we want:

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

then we can use board[x][y] to update our board, where x and y are the user guesses


#7

yessssss I did it I did it danz-danz-danz lalala thank you a lot)


#8