Page 1 of 1

= = Suppose the text file myname.txt contains three lines, each terminated by a newline ('\n'). Suppose the code below i

Posted: Fri Apr 29, 2022 6:53 am
by answerhappygod
Suppose The Text File Myname Txt Contains Three Lines Each Terminated By A Newline N Suppose The Code Below I 1
Suppose The Text File Myname Txt Contains Three Lines Each Terminated By A Newline N Suppose The Code Below I 1 (53.82 KiB) Viewed 20 times
= = Suppose the text file myname.txt contains three lines, each terminated by a newline ('\n'). Suppose the code below is executed, yielding the 4 lines of output that follows it: file_ref = open ("myname.txt","r") aline = file_ref.readline() bline = file_ref.readline() cline = file_ref.readline() print (aline.replace('-''\n') +bline+cline) file_ref.close() nd Output (4 lines with 2 line empty): Moxie = = -Bittersweet Soda Determine the original three lines in myname.txt then modify this input file to contain them. Thus, running the code should yield the given 4 lines of output. Don't alter any of the above specified code: just modify myname.txt and its contents for this problem.