[Solved] How to run something on each line of txt file?


You can use a for loop:

for i,line in enumerate(textFile):
    #code to run on each line  

Where line is the value of the current line in the loop and i is the line number so let’s say your text file was:

John
Doe

Then the for loop would be:

i as 0
line as John

on the first run and so on.

1

solved How to run something on each line of txt file?