Problem with raw_input (Battleships)


I have a problem with the raw_input function. I call it two times, to write the row and the column, but it seems to work just one time. It did work during previous steps and I didn’t change anything in the code, but now it just lets me put only one number.

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

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

This is the part where it stops working correctly. It looks like this on the console:

Anyone had similar problem?


It must have had a number from somewhere or it’d crash when attempting to convert the col to integer

This would be codecademy’s fault, perhaps if you’re lucky reloading “fixes” it, otherwise you could skip taking input and write those values directly in the code instead


I reloaded the page and it worked, thank you :slight_smile:


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