I want to be able to identify all of the positions where a word appears in a sentence.
For example: Hello my name is Ben and his name is Fred.
If I input 'name' it should return: This word occurs in the places: 3 and 8
Below is my code however it will only return the first value.
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.')