Lecture Notes on 22 Jul 2013 # reverses the lines in a file def reverse_file (fileA, fileB): lines = [] inFile = open (fileA, 'r') for line in inFile: lines.append (line) inFile.close() lines.reverse() outFile = open (fileB, 'w') for line in lines: outFile.write (line) outFile.close() # makes a copy of a file def copy_file (fileA, fileB): inFile = open (fileA, 'r') outFile = open (fileB, 'w') fileContent = inFile.read() inFile.close() outFile.write (fileContent) outFile.close() def main(): # prints the indices of all the s's s = 'sleeplessness' limit = len (s) for i in range (limit): if (s[i] == 's'): print (i, end = ' ') print () # prints all the substrings of s s = 'abcd' window = len (s) while (window > 0): i = 0 while (i + window <= len(s)): print (s[i: i + window]) i = i + 1 window = window - 1 copy_file ('rhyme.txt', 'copy_of_rhyme') reverse_file ('rhyme.txt', 'reverse_of_rhyme') main()