PageRenderTime 45ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/PythonVillage/INI5.py

https://github.com/usnish/RosalindProblems
Python | 20 lines | 9 code | 8 blank | 3 comment | 2 complexity | ae3fb2ca732666c7679a0ac88df3717e MD5 | raw file
  1. #PYTHON VILLAGE PROBLEM #5: Reading and Writing Files
  2. #Given: A file containing at most 1000 lines.
  3. #Return: A file containing all the even-numbered lines from the original file. Assume 1-based numbering of lines.
  4. inputfile = open('input.txt','r')
  5. outputfile = open('output.txt','w')
  6. count = 0
  7. for line in inputfile:
  8. if count%2 != 0:
  9. outputfile.write(str(line))
  10. count = count + 1
  11. inputfile.close()
  12. outputfile.close()