Int(raw_input("something")) function doesn't work in Python lesson pages

I try to going though Python lesson pages but anyhow 'int(raw_input())" function doesn’t work at any page(since 2 hours ago?) of Python lesson and it makes me crazy.

Following is the error message:

File “python”, line 22, in
ValueError: invalid literal for int() with base 10: ‘SCT’

Is there anyone suffering same problem??

My code is following and it doesn’t work on lesson page.

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)

print_board(board)

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)
print ship_row
print ship_col
guess_row = int(raw_input("Guess Row: "))
guess_col = int(raw_input("Guess Col: "))

# Write your code below!
if guess_row == ship_row and guess_col == ship_col:
  print "Congratulations! You sank my battleship!"   
else:
  if guess_row not in range(5) or \
    guess_col not in range(5):
    print "Oops, that's not even in the ocean."
  elif board[guess_row][guess_col] == "X":
    print "You guessed that one already"
  else:
    print "You missed my battleship!"
    board[guess_row][guess_col] = "X"
  print_board(board)

Does SCT look like a number to you? Try entering a valid number from 0 to 4.

1 Like

No, that error message occurs before I enter anything

Actually, I cannot enter anything on that page…

It could be an SCT problem, then. You could try to work around it by commenting out the input statements and just set your two guess coordinates to match the computer’s.

guess_row = ship_row
guess_col = ship_col

Let us know if this works, please. Thanks.

1 Like

It works fine with commenting out that line

1 Like

Sometimes, error occurs in different way as following captured picture.
capture

So could you tell me if there is any error in my code?

I really wanna going through these lecture.

Again, it looks like the raw_input() function is disabled or malfunctioning. Try a hard page refresh (Ctrl F5) and see if it will run, then. If not. set your guesses to arbitrary values within range.

1 Like

This issue happened after the session timed out. Yeah, it appears to be a bug and should be fixed.
Seems like the raw_input() handle is lost.
As a work-around, I kill the codecademy window, restarted it and log in again.
It remembered where you left off and raw_input() worked again.

I am facing the same issue, even after refreshing it doesn’t work for me. Constantly says, there is also something wrong with my “Script8.py” and i have to reset the code, after reset it have changed all my script’s codes to the code in “Script11.py”, even that is with lots of mistakes and error and misprints. But still now i am unable to run my code successfully. Please help me.

That is a duplicate of my code; doesn’t work. Doesn’t print ship-row or ship_cpol. It did once but now fails. Guess Row worked at one time, but no nore; same withy guess Col. Something wrong with raw_input.

Neither can I. script.py really sucks!!!

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