'Python is breaking a line in output

I have created a fairly large matrix (20x20) and want to save it to a file. Here's the part of the code that prints it:

file2=open('1.2.dat', 'w')
file2.write(str(hamil2[:][:]))    
file2.close()

Here is the output.

How can I fix it so I don't have a line break? I want each row of the matrix to be one line.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source