Make a list


Error message is saying - Looks like you don’t have 5 rows in your list

But I do get the following output of my code:

[[‘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’]]

But they are not in rows.

Battleships - Make a list

Here is my code:

board = []

def one_row():
  return ["O"] * 5
def full_board(lists):
  board = []
  for i in range(0,5):
  return board

print full_board(one_row())

I am not seeing what I am doing wrong here. Any pointers are really appreciated. Thank you.


Suggest you to do the following for that excercise in order to work:
for x in range(0,4):

print board


Thank you for giving me a solution. I guess creating functions was unnecessary.
But what I don’t get is - How do you get all your “O”-rows in a row, and I don’t?. We still get the same result, but displayed differently.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.