converting a string to a list from a text file

If you look at the Python documentation (which you should!) you can see that readlines() returns a list containing every line in the file. To then split each line, you could do something along the lines of:

with open('times.txt') as f:
    for line in f.readlines():
        print line.split()

Leave a Comment