Okay—now for the fun! We have the actual location of the ship and the player’s guess so we can check to see if the player guessed right.

For a guess to be right, guess_col should be equal to ship_col and guess_row should be equal to ship_row.

if guess_col == 0 and guess_row == 0: print "Top-left corner."

The example above is just a reminder about if statements.



On line 29, add an if to check if guess_row equals ship_row and guess_col equals ship_col.

If that is the case, please print out "Congratulations! You sank my battleship!"

When you run this code, be sure to enter integer guesses in the panel where it asks for “Guess Row” and then “Guess Col”.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?