Hide... Oops, try again. Did you create a function called random_row?


#1




Oops, try again. Did you create a function called random_row?


If I put in something like
random_row(board)
random_col(board)

under it, I get this error message "Traceback (most recent call last):
File "python", line 17, in
File "python", line 14, in random_row
NameError: global name 'random' is not defined"
If it is not indented and if it is then I get the same error as mentioned above "Oops, try again. Did you create a function called random_row? "


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 elow!
def random_row(board):
    return random.randint(0, len(board)-1)
def random_col(board):
    return random.randint(0, len(board[0])-1)


#2

Hi, @chipcoder12911 ,

If you use this import ...

from random import randint

... you must change this ...

return random.randint(0, len(board)-1)

... to this ...

return randint(0, len(board)-1)

Also revise this in a similar manner ...

return random.randint(0, len(board[0])-1)

#4

Thank you man it worked! also appreciate the quick response.


#5