Hide


#1

Hi everyone and thanks in advance. My code below is not printing the rows/columns of O's so they look nice. Rather, when I hit submit, this is what the it looks like: 

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

What have I missed? 

from random import randint 

board = []

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

def print_board(board):
    for row in board:
        print " ".join(row)

# Add your code below!
def random_row(board):
    return randint(0, len(board) -1)
    
def random_col(board):
    return randint(0, len(board) -1)

random_row(board)
random_col(board)

print(board)

#2

this..

You just have to call print_board() (with board argument)function to see formatted board of O's!


#3

ahh there's where I was missing it nice.

Cheers.


#4

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