rstrip not removing newline char what am I doing wrong? [duplicate]

Posted on

Question :

rstrip not removing newline char what am I doing wrong? [duplicate]

Pulling my hair out here… have been playing around with this for the last hour but I cannot get it to do what I want, ie. remove the newline sequence.

def add_quotes( fpath ):

ifile = open( fpath, 'r' )
ofile = open( 'ofile.txt', 'w' )

for line in ifile:
if line == 'n':
ofile.write( "nn" )
elif len( line ) > 1:
line.rstrip('n')
convertedline = """ + line + """", ""

Leave a Reply

Your email address will not be published. Required fields are marked *