7. 13 Hide


#1



https://www.codecademy.com/courses/python-beginner-en-4XuFm/0/7?curriculum_id=4f89dab3d788890003000096#

i don't know why this code doesn't work.


Replace this line with your code. 
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 randit(0, len(board) - 1)

def random_col(board):
    return randit(0, len(board) - 1)

random_row((board)
random_col(board)


#2

the error is:Oops, try again. Did you create a function called random_row?
but i actually made a function called random_row


#3

without running the code, i think the error is caused by this line:

random_row((board)

it has two opening brackets, and one closing. I think you accidentally hit the ( key twice


#4

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

def random_col(board):
    return randit(0, len(board) - 1)

random_row(board)
random_col(board)

done, but it tell me the same error, it doesn't recognize the function random_row,
i think it is a bug


#5

sloppy me, in your random_row and random_col function, you have: randit, this should be randint, which is short for random integer, which is what you want, you want to generate a random integer)


#6

Ok solved :slight_smile: thank you


#7

You have randit().Its randint() and an extra open in random_row((board)


#8

why did you reply to this topic? The topic is solved, i already told netboy about both this problems


#9

hey buddy its randint(0,len(board)-1) and not randit(0, len(board) - 1)