How order words from a text file in Python

I’ve written a Python script which I use to print out all words from a text file:

file = open(raw_input("Enter a file name: "))

for line in file:
    for words in line.split():
        print words

But how to print them out in order?

Source: python

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.