iterating over lines in a file 1

iterating over lines in a file

for line in myFile.readlines():
    statement1
    statement2
    ...

Here is what the above code is Doing:
1. Open the file “myFile.txt”
2. Read the file line by line
3. For each line, do the following:
a. statement1
b. statement2

Similar Posts