I'm having problems printing this 2d array for my Battleship game.
class Battleship:
def __init__(self):
self.__init__()
def board(self, locate):
locate = []
for i in range(10):
locate.append([])
for j in range(10):
locate[i].append(0)
for i in range(10):
for j in range(10):
locate[i][j] = '%s,%s'%(i,j)
print(locate)
I found how to initialise the array here: How to initialise a 2D array in Python? This is where I found the code sample to iterate over the 2d array, but it doesn't work for me: Iterating over a 2 dimensional python list
Can you give me some help please?