how to read files in python

with open("file.txt") as file_in:
    lines = []
    for line in file_in:

Here is what the above code is Doing:
1. We open the file and store the file object in the variable file_in.
2. We create an empty list called lines.
3. We iterate over the file object file_in.
4. For each line in file_in, we append the line to the list lines.
5. After the loop, we close the file.