FAQ: Learn Python - Battleship - It's Not Cheating—It's Debugging!


This community-built FAQ covers the “It’s Not Cheating—It’s Debugging!” exercise in Codecademy’s lessons on Python.

FAQs for the Codecademy Python exercise It’s Not Cheating—It’s Debugging!:

Join the Discussion. We Want to Hear From You!

Have a new question or can answer someone else’s? Reply (reply) to an existing thread!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources about Python in general? Go here!

Want to take the conversation in a totally different direction? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account, billing, Pro, or Pro Intensive? Reach out to our support team!

None of the above? Find out where to ask other questions here!

Hi, I have a problem with this exercise. It occurred in the previous lesson, “…and Seek!” as well. It seems like my code is correct, it definitely was in the previous lesson when my code wouldn’t function, and I was wondering if it’s a bug. here’s my 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)

Add your code below!

print ship_row
print ship_col
guess_row = int(raw_input("Guess Row: "))
guess_col = int(raw_input("Guess Col: "))

But when I Run it, I get this
Guess Row: Traceback (most recent call last):
File “python”, line 23, in
ExecTimeoutException: Program took too long to terminate. the error message is it took too long to terminate.
If it’s a problem with my code, what is the problem?
I have also tried this code with numbers put in the "Guess Row: " and "Guess Col: " strings. I get the same response.


I am also getting the same error.


Hey ! I’ve got the same error here on google chrome. I’m stuck because of this ^^

1 Like

This lesson is broken. Same as everyone commented above, timeout errors.

I was experiencing the same problem.
However, I was able to resolve it by I switching browsers. I was able to get it working in both Chrome and Safari.

Note I tried all browsers on a Mac

hi all! I encountered the this “problem” and got it resolved eventually by doing this:

after you hit run to the code, the console will display something like this:
1 (a randomised row number)
2 (a randomised column number)
Guess Row: (plus a flashing input cursor!)

so the system is waiting for the user’s input to make a guess, if you just stay and wait, the timeout error will eventually occur. What you should actually do is to make the two guesses by inputting something after “Guess Row:” and “Guess Col:” (and hit enter). Then this session will be done and we can go to next

1 Like