Mir Khashkhash Mir Khashkhash - 3 months ago 11
Python Question

How to read the entire file into a list in python?

I want to read an entire file into a python list any one knows how to?

Max Max
Answer
print "\nReading the entire file into a list."
text_file = open("read_it.txt", "r")
lines = text_file.readlines()
print lines
print len(lines)
for line in lines:
    print line
text_file.close()
Comments