how to create a text file through python
<p>Looking to create a program that needs to take the users sentence, list its positions, and also identify each individual positions of word and then save a list of the position numbers to a file, I've got as far as:</p>

<pre><code>   text = input('Please type your sentence: ')
sentence = text.split()
word= input('Thank-you, now type your word: ')

    if word in sentence:
            print ('This word occurs in the places:', sentence.index(word)+1)

elif word not in sentence:
        print ('Sorry, '+word+' does not appear in the sentence.')


text=text.lower()
words=text.split()
place=[]

for c,a in enumerate(words):
    if words.count(a)&gt;2 :
    place.append(words.index(a+1))
    else:
    place.append(c+1)

print(text)
print(place)
</code></pre>

<p>this is what I have so far but can't seem to find anything that creates any files, I don't really know how to go about that, any help with the direction to head in would be much appreciated.</p>

<p>Use the open function with the 'w' or 'a' access modifier.</p>

<p>e.g.</p>

<pre><code>fo = open("foo.txt", "w")
</code></pre>

python file