A program that reads a file called 'test.txt' and prints out the contents on the screen after removing all spaces and newlines. punctuations will be preserved.
A computer follows a collection of instructions called a program to carry out a certain task. The size of a computer program affects the likelihood that an error may occur.
# Read lines as a list
fh = open("transfer-out/" + file, "r")
lines = fh.readlines()
fh.close()
# Weed out blank lines with filter
lines = filter(lambda x: not x.isspace(), lines)
# Write "transfer-out/"+file+".txt", "w"
fh = open("transfer-out/"+file, "w")
#fh.write("".join(lines))
# should also work instead of joining the list:
fh.writelines(lines)
fh.close()
Learn more about Program here-
https://brainly.com/question/3224396
#SPJ4