7/13 [solved] Hide... | What is wrong with my code?


#1

what is wrong with my code?
I'm confused of what is happening...

board = []

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

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

def random_row(board):
    from random import randint
    ship_row = randint(0,len(board) - 1)
    return ship_row
    
def random_col(board):
    from random import randint
    ship_col = randint(0,len(board) - 1)
    return ship_col

print random_row(board)
print random-col(board)

#2

Never mind, this is the correct 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)

def random_row(board):
    return randint(0, len(board) - 1)

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

ship_row = random_row(board)
ship_col = random_col(board)