Python Forum
Do not get how Python iterates over a file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Do not get how Python iterates over a file
#7
I guess, the last line in your file1 does NOT have new line
i.e. the line is just 3
At the same time the third line in file2 has new line, i.e. it is 3\n
So both lines are not equal.

You can strip the new line char from the lines before comparison. This will also take care of the extra blank line in your output between --1 and --2
tester_V likes this post
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
RE: Do not get how Python iterates over a file - by buran - Jan-27-2023, 11:00 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Still do not get how Python iterates over a file tester_V 13 3,859 Aug-24-2021, 05:10 AM
Last Post: naughtyCat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020