#File: countSpace.py #Author: Prof. Neary #Date: 11/03/2016 #Section: 07 #Description: # This file reads known input in "spaced.txt" and counts the number # of whitespace characters in the file. It prints out that number, # and writes every non-whitespace character into another file. def main(): inputFile = open("spaced.txt", "r") outputFile = open("unspaced.txt", "w") everything = inputFile.read() spaceCount = 0 for thing in everything: if thing == " " or thing == "\n" or thing == "\t": spaceCount = spaceCount + 1 else: outputFile.write(thing) print("The number of whitespace:",spaceCount) inputFile.close() outputFile.close() main()