It's Not Cheating—It's Debugging!


#1

Stucked here for hours:

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

Thas the error I get:

Guess Row: Traceback (most recent call last):
File “python”, line 23, in
ValueError: invalid literal for int() with base 10: ‘SCT’

What to do?


#2

Hello,

I need some help please, I have been stuck and none is replying on my topic in formus.
Page just keep on loading and doesn’t let me go forward:
Link of the exercise on Python: https://www.codecademy.com/courses/learn-python/lessons/battleship/exercises/its-not-cheatingits-debugging?action=lesson_resume

Error: Guess Row: Traceback (most recent call last):
File “python”, line 22, in
ValueError: invalid literal for int() with base 10: ‘SCT’

Please help me, thank you!


#3

We will need to see you complete code, preformatted so the indentation is visible.


#4
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!


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

#5

For this exercise, show the ship row and column before the inputs so you can test those values. Be sure to enter only numbers, and not just Enter.


#6

Edit: I reset the exercise which fixed it,

I’m having the same issue. When I load this page, the existing code disappears. When I paste in the code below (which matches the code above) and click run, the page just loads forever and produces no output.

I can’t progress at all! Please help.

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!

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


#7