Play It, Sam

You can successfully make one guess in Battleship! But we’d like our game to allow the player to make up to 4 guesses before they lose.

for turn in range(4): # Make a guess # Test that guess

We can use a for loop to iterate through a range. Each iteration will be a turn.



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.

Folder Icon

Take this course for free

Already have an account?