7. Hide.... ---- One parameter?


#1
from random import randint 

board = []

board_length=5

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

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)

Getting the error:

Oops, try again. Your random_row function should take exactly one parameter.

Traceback (most recent call last):
  File "python", line 21, in <module>
  File "python", line 16, in random_row
TypeError: unsupported operand type(s) for -: 'list' and 'int'

What am I doing wrong?


#2

Fixed it by making board an int - codecademy is letting me progress so hope I'm doing it right!

from random import randint 

board = []

board_length=5

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

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

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

#5