Join method is not working

Asked

Viewed 38 times

3

Good! I am creating the game Battleship and I found a problem creating the board.

Code:

board = []

for x in range(15):
    board.append(["O"] * 15)

def print_board(board):
    for row in board:
        print (" ").join(row)

And when I print the board give me this mistake:

  print (" ").join(row)
AttributeError: 'NoneType' object has no attribute 'join'

And I don’t understand what’s wrong... Someone can help me?

1 answer

2

Probably the parenthesis sign in the command print should be:

for row in board:
  print(" ".join(row)) # -> aqui!!

After the change, the program prints:

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 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 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
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 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 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
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 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 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
  • had been the real problem!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.