# mirror.py, by chaynes@indiana.edu import image def mirror(lst): """Copy the values in elements in the first half of lst into elements in the second half of lst, in reverse order. """ for i in range(len(lst) / 2): lst[len(lst) - 1 - i] = lst[i] def mirror_matrix(matrix): """Call the mirror function on each row of matrix.""" for index in range(len(matrix)): row = matrix[index] mirror(row) def main(): """Show bonsai.jpg, and then show and save its mirror image.""" m = image.read('bonsai.jpg') mirror_matrix(m) im = image.new(m) im.show() im.save('mirror.jpg') if __name__ == '__main__': main()