7. Hide


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)

def random_row(board):
    randint(0, len(board) - 1)
def random_col(board):
    randint(0, len(board) - 1)

Oops, try again. It looks like your row bounds are not correct.

if I change:

def random_col(board):
    randint(5, len(board) - 1)

I pass, but I get an error
Traceback (most recent call last):
File "python", line 19, in
File "python", line 16, in random_col
ValueError: empty range for randrange() (5,5, 0)

Can't figure out what's with this


this function (and random_col):

def random_row(board):
    randint(0, len(board) - 1)

now you generated a random integer (0,1,2,3 or 4) but you don't do anything with it, you should return it:

def random_row(board):
    return randint(0, len(board) - 1)

You know how returns work right? You need to return for the next step, so you know where you ships are hiding, otherwise you don't know (which is going to make the game really difficult)


oh yeah you are rigth, tnx. It even says to return randint