def main():
f=open("fileread.txt","r")
for x in f:
p=x.split(" ")
print(p)
main()
I have written this code for reading a matrix from a file and write it into the console. But I got unexpected output. The output should be
['5', '6', '9', '7']
['1', '7', '9', '6']
['4', '5', '6', '3']
['14', '25', '9', '6']
but I got
['5', '6', '9', '7\n']
['1', '7', '9', '6', '\n']
['4', '5', '6', '3', '\n']
['14', '25', '9', '6']
My Text file is written just like that :
5 6 9 7
1 7 9 6
4 5 6 3
14 25 9 6