How can I redirect the output to be put into a file in python (version 3.3.3)?
<pre><code>sentence = "ASK NOT WHAT YOUR COUNTRY CAN DO FOR YOU ASK WHAT YOU CAN DO FOR YOUR COUNTRY"
s = sentence.split() 
another = [0]
print(sentence)
for count, i in enumerate(s): 
    if s.count(i) &lt; 2:
        another.append(max(another) + 1)
    else:
        another.append(s.index(i) +1)
another.remove(0)
print(another)
</code></pre>

<p>I am guessing you want the sentence put into a text file? If so, here is the code:</p>

<pre><code>text_file = ("textfile.txt", "w")
text_file.write(sentence)
text_file.close()
</code></pre>

<p>Make sure textfile.txt is in the same folder as your program.</p>

python