9. It's Not Cheating—It's Debugging!


#1

https://www.codecademy.com/courses/learn-python/lessons/battleship/exercises/its-not-cheatingits-debugging?action=lesson_resume&link_content_target=interstitial_lesson

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)

# Add your code below!
print ship_row
print ship_col
guess_row = int(raw_input("Guess Row: "))
guess_col = int(raw_input("Guess Column: "))

Hello,

I’m trying to run his exercise but when i press run it loads forever.


#2

I also am stuck on this step. I hit run and no matter what I have in the box it just hangs. I tried to get errors to pop up and nothing happens.


#3

This may not help to see how the real program works, but it may be a necessary workaround to let you proceed.

print ship_row
print ship_col
guess_row = ship_row
guess_col = ship_col

#4

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