I\'m a lumberjack and I\'m okay, I sleep all night and I work all day. He\'s a l
ID: 3795683 • Letter: I
Question
I'm a lumberjack and I'm okay, I sleep all night and I work all day. He's a lumberjack and he's okay,
***PLEASE WRITE OUT THE EXCAT CODE OR SCREEN SHOT FROM PYTHON**** (NO UNNECESSARY WORDS PLEASE)
Problem 2: You are given a test file named as testFile.txt with a single sentence of 20 words. Read the file, then insert carriage return characters (n and write the test to a new text file that will be composed of four lines of five words Sample output of new text file: newFile txt I'm a lumberjack and I'm okay, I sleep all night and I work all day. He's a lumberjack and he's okay,Explanation / Answer
f = open("testFile.txt",'r')
line = f.readline()
line = line.split()
out = open("newTextFile.txt",'w')
out.write(" ".join(line[0:5])+" ")
out.write(" ".join(line[5:10])+" ")
out.write(" ".join(line[10:15])+" ")
out.write(" ".join(line[15:20])+" ")
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.