Dont know what am doing wrong


Add a FOR loop that repeats the guessing and checking part of your game for 4 turns, like the example above.

At the beginning of each iteration, print "Turn", turn + 1 to let the player know what turn they are on.

Indent everything that should be repeated.

for turn in range(4):
  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 sunk my battleship!"
    if (guess_row < 0 or guess_row > 4) or (guess_col < 0 or guess_col > 4):
      print "Oops, that's not even in the ocean."
    elif(board[guess_row][guess_col] == "X"):
      print "You guessed that one already."
      print "You missed my battleship!"
      board[guess_row][guess_col] = "X"
    # Print (turn + 1) here!
    print "Turn ",str(turn + 1)

code works fine but am still wrong according to codecademy.
Any help


just use print "Turn", turn + 1, trying to alter will very likely cause an error.


i think it’s the position i placed the print statement that’s causing the problem, the lesson placed it right under the for loop and it worked same as the one i posted above but per the lesson, the position made it not correct and not the code.
some of these things make u think you are wrong


make sense the solution does this, its as stated in the instructions

But it doesn’t have to cause the problem, using print "Turn ",str(turn + 1) will result in Turn__1 (replaced spaces with underscores), which is too many spaces, which also might trip an error


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