brewersfan1976

ch5-ex3.py

Aug 7th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.28 KB | None | 0 0
  1. # This program reads data from a sample text file
  2. # and prints out the lines of text in reversed order
  3. # in another text file
  4.  
  5. f = open("sample2CAP.txt", "r")
  6. new_file = open("reversed.txt", "w")
  7.  
  8. for line in reversed(list(f)):
  9.     new_file.write(line)
  10.  
  11. f.close()
  12. new_file.close()
Advertisement
Add Comment
Please, Sign In to add comment