Battleship: Custom Print



When I run the below code it will print out the five rows of O’s but under that will have “None.” I don’t know why that is, if I should leave it, or if there’s someway to delete it. Thanks for any help.

board = []


for each_number in range(5):
  board.append(["O"] * 5)

def print_board(board_in):
  for row in range(5):
    print board[row]

print print_board(board)

And this is what prints out each time:

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


because you’re printing the board inside the function print_board, but when you call it you are calling print print_board
print_board doesn’t have a return so by default it returns none
just call print_board without the print statement


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