Hide


#1


Hide...

Getting an error message "your choices are not random enough. Try running it again", no amount of re-running fixes it.
Code is as follows:


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(1, len(board) - 1)

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

random_row(board)
random_col(board)


#2

Then it would seem pretty likely that there's something off about the random choices being made right? And that's something you could look at by running those choices several times and looking at the outcomes, checking that it's able to choose all valid choices

If you have reason to think that the use of random isn't right, then it would be a good idea to read the documentation. google python random randint and look for results from docs.python.org and read up on how that function can be used


#3

I guess it's because you started the range with index 1 which means the first one in the row or col(index 0) is not random? hope it help:P


#4

That did it, thank you!


#5

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