Learn
Battleship!
Game Over

If someone runs out of guesses without winning right now, the game just exits. It would be nice to let them know why.

Since we only want this message to display if the user guesses wrong on their last turn, we need to think carefully about where to put it.

  1. We’ll want to put it under the else that accounts for misses
  2. We’ll want to print the message no matter what the cause of the miss
  3. Since our turn variable starts at 0 and goes to 3, we will want to end the game when turn equals 3.

Instructions

1.

Add an if statement that checks to see if the user is out of guesses.

  • Put it under the else that accounts for misses.
  • Put it after the if/elif/else statements that check for the reason the player missed. We want "Game Over" to print regardless of the reason.

If turn equals 3, print "Game Over".

Folder Icon

Take this course for free

Already have an account?