Python Forum
Printing lines in a basic text file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Printing lines in a basic text file
#6
@perfringo: I really like your use of enumeration.

First you open the text file as a variable. Then for the two iterators inside the each line of the text file which you’ve declared, the first iterator, i, corresponds to each line. When i reaches line number 4, you print the other iterator, v. Then the operation is terminated.

A few days ago I was having difficulty grasping the concept of enumeration. There is a question on SO titled, “What does enumerate mean?” which has quite a number of answers explaining enumeration in general. It all went over my head when I was reading it a few days ago. But your use of enumeration is clear and easily understood in the context of printing line 5 in my text file. Thank you for the clarification, @perfringo.
Reply


Messages In This Thread
Printing lines in a basic text file - by Drone4four - Aug-16-2018, 12:08 AM
RE: Printing lines in a basic text file - by Drone4four - Aug-16-2018, 02:02 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Thumbs Up Need to compare the Excel file name with a directory text file. veeran1991 1 1,177 Dec-15-2022, 04:32 PM
Last Post: Larz60+
  Delete multiple lines from txt file Lky 6 2,397 Jul-10-2022, 12:09 PM
Last Post: jefsummers
  python-docx: preserve formatting when printing lines Tmagpy 4 2,208 Jul-09-2022, 01:15 AM
Last Post: Tmagpy
  Modify values in XML file by data from text file (without parsing) Paqqno 2 1,765 Apr-13-2022, 06:02 AM
Last Post: Paqqno
  Editing text between two string from different lines Paqqno 1 1,353 Apr-06-2022, 10:34 PM
Last Post: BashBedlam
  failing to print not matched lines from second file tester_V 14 6,269 Apr-05-2022, 11:56 AM
Last Post: codinglearner
  Extracting Specific Lines from text file based on content. jokerfmj 8 3,156 Mar-28-2022, 03:38 PM
Last Post: snippsat
  Converted Pipe Delimited text file to CSV file atomxkai 4 7,133 Feb-11-2022, 12:38 AM
Last Post: atomxkai
  raspberry use scrolling text two lines together fishbone 0 1,485 Sep-06-2021, 03:24 AM
Last Post: fishbone
  Importing a function from another file runs the old lines also dedesssse 6 2,662 Jul-06-2021, 07:04 PM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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