A text file named input.txt contains zero or more words in each line. Write a program that reads the above file and creates a file named output.txt with all the words appearing in the input, but with exactly one word per line. The input file may be empty.
1
Expert's answer
2015-05-01T12:24:12-0400
"""Example of input: abc def ge Example of output: abc def ge """ fid = open("output.txt", 'w'); # read all lines in file with open("input.txt") as f: lines = f.readlines(); # iterate by lines for line in lines: words = line.split(); if len(words) > 0: for word in words: fid.write(word + "\n"); fid.close();
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments