Possible bug with 7 (Hide)


#1



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


While my code seemed to run properly (no errors, returned "None"), but the problem was deemed incorrect with the message: Oops, try again. Your random_row function should take exactly one parameter. The only parameter was board (see below code).

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 randint(0, len(board) - 1)
    
def random_col(board):
    return randint(0, len(board) - 1)
    
random_row = random_row(board)
random_col = random_col(board)


#2

Your code is overwriting the functions with numbers. Once your code runs, the SCT cannot run its test.

You will have to refresh the page to restore the namespace to original form. Then use variables that are NOT the same as your function names.


#3

Thanks. Missed the instructions to use ship_row and ship_col.


#4

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