# Code for Dr. Rheingan's section of CMSC 201 def main(): #open input file : spaced.txt #open output file: unspaced.txt spacedFile = open("spaced.txt", "r") unspacedFile = open ("unspaced.txt", "w") #read input from file into variable space = spacedFile.read() #remove whitespace nospace = space.split() unspace = "".join(nospace) #write output file unspacedFile.write(unspace) # count the number of whitespace characters print ("There were", len(space) - len(unspace), "spacing characters in the file.") # close input and output file spacedFile.close() unspacedFile.close() main()