Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def open_file(filename): #opens a txt
- file_object = open(filename, "r")
- return file_object
- def read_file(file_object): #reads a txt
- for line in file_object:
- line = line.strip()
- line = line.rstrip(",")
- start = line[0]
- end = line[-1]
- first = line[1:-1:2]
- second = line[2:-1:2]
- output=""
- for i in range(len(second)):
- output += second[i]
- output += first[i]
- print(start+output+end, end = " ")
- def main():
- filename = input("Enter name of file:")
- file_object = open_file(filename)
- read_file(file_object)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement