7. Hide... range() takes no arguments (2 given)


#1

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[0]) - 1)
    
   
random_row(board)
random_col(board)`

is returning:

 Traceback (most recent call last):
  File "python", line 5, in <module>
TypeError: range() takes no arguments (2 given)

#2

Hi blemming,

I can get it to work on the repl as well as on the exercise. Are you sure you are trying this code only and not any alternate code? I am asking this because it's the first time when an error could be raised:

TypeError: range() takes no arguments (2 given)

for a thing that's actually correct (range does take 2 arguments)


#3

Finally got it to work , just restarted my browser.

Weird, thanks a lot tho :slightly_smiling:


#4

For the second function you wrote for that level:

why did you use len(board[0] instead of just len(board) it works both ways, I know bc I did it without the brackets, and it works the same but I'm just a little curious as to why did you try to use that one, instead? and how come both ways works?