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:
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)>2 :
place.append(words.index(a+1))
else:
place.append(c+1)
print(text)
print(place)
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.