Reverse line in a file problem.

Page 1 of 1

1 Replies - 452 Views - Last Post: 08 November 2012 - 11:06 AM Rate Topic: -----

#1 medaa   User is offline

  • D.I.C Head

Reputation: 6
  • View blog
  • Posts: 106
  • Joined: 24-October 12

Reverse line in a file problem.

Posted 08 November 2012 - 11:03 AM

Hey, so the idea of this program file is open and read a file then take all the content of that file and reverse it into the output file. My problem is the reversing, the first part works, but then I keep getting " File "/Users//Lab 8 part 2", line 16, in <module>
builtins.AttributeError: '_io.TextIOWrapper' object has no attribute 'reverse" ......can someone please help me.

[import os.path
while True:
try:
name1=input("Enter input name:")
infile=open(name1,"r")
name2=input("Enter output name:")
while(os.path.isfile(name2)):
name2=input("File exists. Enter new output name:")
ofile=open(name2, "w")
break
except:
print("Error in code")



infile.reverse()
for line in infile:
print(line)]

Is This A Good Question/Topic? 0
  • +

Replies To: Reverse line in a file problem.

#2 Dogstopper   User is offline

  • The Ninjaducky
  • member icon

Reputation: 2972
  • View blog
  • Posts: 11,223
  • Joined: 15-July 08

Re: Reverse line in a file problem.

Posted 08 November 2012 - 11:06 AM

You already have a topic open on this subject. Please do not double post.

Thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1