How to read a file line-by-line into a Python list?

You can use open() method in Python to open a file and then read the file line by line using a for loop as shown in the below example –