CA Python2 7.2.12 Bad Aim and .13 Not Again

https://www.codecademy.com/courses/learn-python/lessons/battleship/exercises/bad-aim?action=resume_content_item

It would be great if somebody explain me what does it mean: “They can guess a spot they’ve already guessed”. As far as I saw before, the code below generates NEW positions for every attempt, so, there are no any “already guessed” places in this version of game. Thank you in advance.


from random import randint

def random_row(board):

  return randint(0, len(board) - 1)

def random_col(board):

  return randint(0, len(board[0]) - 1)

1 Like

That code doesn’t do much at all yet, it defines two functions, and then exits.
You’d need a loop which repeatedly asks for a guess and updates the game state

Oh and random.randrange has an exclusive upper bound, so you wouldn’t have to pass in 0 and subtract 1, you could instead:
random.randrange(len(board))


I updated your post to change

'''

(single quotes)
into

```

(backticks/backquotes)

1 Like

Please read what I am asking about.
I’m not asking how much this code does.
I do not ask if I need a loop.
I ask a completely different question.

1 Like

Like you say, there’s never a second guess.
What is missing is a loop, so that there is a second guess.

generate the board

for each turn
    where does the user shoot?
    is that a miss?
    have they shot there before?
    is it a hit?
    mark where the user shot
    ... whatever else would happen during a turn
1 Like