12. Bad Aim - Good output but error message says otherwise


#1

Code

https://www.codecademy.com/courses/python-beginner-en-4XuFm/1/2?curriculum_id=4f89dab3d788890003000096

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"
else:
print "You missed my battleship!"
board[guess_row][guess_col] = 'X'
print board

Output

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
Guess Row: 4
Guess Col: 6
0
1
Oops, that's not even in the ocean
[['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']]
None

CodeAcademy error message

Oops, try again. Make sure you print "Oops, that's not even in the ocean." if the user guesses a row or column that is off the board.

Hmm....it did print out. Assistance would be appreciated.

Thank you,

Melissa


#2

I should have looked at the example below. The problem was that I did not put a period at the end of the sentence.

Melissa


#3

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