SHARE
TWEET

asdfasdf

a guest Sep 22nd, 2019 116 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top