Advertisement
Guest User

asdfasdf

a guest
Sep 22nd, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. def open_file(filename): #opens a txt
  2. file_object = open(filename, "r")
  3. return file_object
  4.  
  5. def read_file(file_object): #reads a txt
  6. for line in file_object:
  7. line = line.strip()
  8. line = line.rstrip(",")
  9. start = line[0]
  10. end = line[-1]
  11. first = line[1:-1:2]
  12. second = line[2:-1:2]
  13. output=""
  14. for i in range(len(second)):
  15. output += second[i]
  16. output += first[i]
  17.  
  18. print(start+output+end, end = " ")
  19.  
  20. def main():
  21. filename = input("Enter name of file:")
  22. file_object = open_file(filename)
  23. read_file(file_object)
  24.  
  25. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement