How do I read every line of a file in Python and store each line as an element in a list?
I want to read the file line by line and append each line to the end of the list.
See Input and Ouput:
with open('filename') as f: lines = f.readlines()
or with stripping the newline character:
with open('filename') as f: lines = [line.rstrip() for line in f]
This is more explicit than necessary, but does what you want.
with open("file.txt") as file_in: lines =  for line in file_in: lines.append(line)