I have array of this integer type:
JavaScript
x
2
1
object = [[6, 0, 2, 3, 5, 0], [0, 2, 1, 0, 3, 2], [6, 0, 1, 0, 4, 1], [6, 1, 1, 0, 3, 2], [6, 2, 1, 2, 1, 2]]
2
How can I save this to an xyz.txt file in this format with 5 lines:
JavaScript
1
6
1
6 0 2 3 5 0
2
0 2 1 0 3 2
3
6 0 1 0 4 1
4
6 1 1 0 3 2
5
6 2 1 2 1 2
6
The following code returns the error
JavaScript
1
4
1
with open('xyz.txt', 'w') as txt_file:
2
for line in object:
3
txt_file.write(" ".join(line) + "n")
4
JavaScript
1
2
1
TypeError: sequence item 0: expected str instance, int found
2