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

Community%20FAQs%20on%20Codecademy%20Python%20Exercises

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
4
3
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.

4 Likes

I am also getting the same error.

1 Like

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

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