I have the following function in python:
def writeWinningBoards():
f = open("goodBoards.txt", "a")
for row in tableros:
for index, value in enumerate(row):
if value == 1:
row[index] = 'x'
elif value == 2:
row[index] = ' '
elif value == 3:
row[index] = 'o'
row = np.array(row).reshape(3,3)
f.write(row)
print row
f.close()
How can a I write to a file, the console representation of the array, when row is printed I have this:
['o' 'o' 'x']
['x' 'x' 'x']
['o' 'x' 'o']
but in the file I get something like this:
x o x o x x o xo o x
How could I do this ? I just want a user-friendly way of storing tic tac toe gameboards for reading.