Play it Sam. What are they looking for? turn +1


#1

My confusion is that I don't know what they want displayed. As the code is below -

for turn in range(4):
print ("Turn " + str(turn+1))
turn=turn+1
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!"
else:
    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."
    else:
        print "You missed my battleship!"
        board[guess_row][guess_col] = "X"
    #  print ("Turn " + str(turn + 1))
    print_board(board)

I get
Let's play Battleship!
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
Turn 1
Guess Row:

And the turn number increments each turn and ends at 4.

If I comment out line 4 and 5, then uncomment the -2nd line ( # print ("Turn " + str(turn + 1))) I get an indicator of what turn I just completed, and it doesnt like that either.

Both ways I get "Oops, try again. Did you remember to print out turn + 1 each turn?"

What is it the spec? If I could just understand what they are asking for I think I would be ok.


#2

Try a lower case t in your turn, if all else fails just put turn +1 with a print,

print("turn". turn + 1)

or

print(turn+1)

#3
for turn in range(4):
print ("Turn " + str(turn+1))
turn=turn+1
guess_row = int(raw_input("Guess Row:"))
guess_col = int(raw_input("Guess Col:"))

Should be:

 for turn in range(4):
     print "Turn", turn+1
     guess_row = int(raw_input("Guess Row:"))
     guess_col = int(raw_input("Guess Col:"))

You shouldn't change turn into a str(string)


#4

This is the code that worked for me, let me know if it did for you. Careful with those indentations :grin:

for turn in range(4):
print "Turn", turn+1
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!"
else:
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."
else:
print "You missed my battleship!"
board[guess_row][guess_col] = "X"
for turn in range(4):
print "Game Over"

print "Turn",turn+1
print_board(board)