Reputation: 787
I'm trying to write some lines in a file.
My problem arises in the output.
The code looks like this:
fileInput = open("file.txt","r+")
fileOutput = open("fileOut.txt","w")
for line in fileInput.readlines():
outputString = functionname+"="+otherfunctionname+str(lineNumber)
fileOutput.write(outputString)
fileOutput.write("\n")
The expected output:
function()=name=123
function1()=name1=1223
Instead the output looks like this:
function()
=name=123
function1()
=name1=1223
I can't figure out what is the problem. Can you give me a hint of what it could be ?
Upvotes: 1
Views: 172
Reputation: 5533
Try outputString = functionname.rstrip()+"="+otherfunctionname+str(lineNumber)
Upvotes: 1