# removeSpaces.py # using functions def main(): fname = input("Please, input a file name where a sentence is stored:") inSource = open(fname) # open file with name fname s = inSource.readline() # reads one line from inSource inSource.close() print("This is the sentence we got from the file:\n",s) s1 = removeSpaces(s) # remove spaces, save the result in s1 print("Here is the line from the file with all the spaces stripped:\n",s1) outSource = open('result.txt','w') # open file 'result.txt' for writing print(s1,file=outSource) # using print instead of outSourse.write(s1) # removes spaces from string sentence, returns result as a string def removeSpaces(sentence): l = sentence.split() return ''.join(l) main()