3. Make a List



"Oops, try again. It looks like you do not have 5 rows in your list."

Exactly what did happen. 5 rows. Is using range really necessary or is Codeacademy really only allowing one way to solve this?

board = []

board_grid = 0

while board_grid < 5:
    print ['O'] * 5
    board_grid = board_grid + 1

Results are:

['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']


i don't think range is needed (i have to try, but it must be possible), but you will need to append your rows to your board array, not print the rows, if you only print the rows, they aren't stored, which becomes a problem later on


Thanks for the explanation about storage. After getting the result I showed here, did what they wanted and everything was fine. Just needed to know why.


well think about it for a second, the code you had in the original question, would only print the board, but not store it. Then how would you know if your ship has been hit? Or not hit? If you store it in a array (multi-dimensional array) you could update the array to indicate a hit or a miss (and check if the user entered something valid)

Does that answer all your questions?


Sure thing, even if the player guessed the correct space, that code would still print a grid of O's.


Yes, exacxtly. you undestand it