Hi all,
can i get a bit of help with my H/W, the task is as follows:
Develop a program that analyses a sentence that contains several words without punctuation. When a word in that sentence is input, the program identifies all of the position the word occurs in the sentence. The system should not be case sensitive: Ask, ask & ASK should be treated as the same word.
For example, in the sentence ASK NOT WHAT YOUR COUNTRY CAN DO FOR YOU ASK WHAT YOU CAN DO FOR YOUR COUNTRY
The word ‘COUNTRY’ occurs in the 5th and 17th positions.
Analyse the requirements for this system and design, develop, test and evaluate a program to locate and return the position(s) of the word you have selected in a particular sentence or return an error message if the word is not in the sentence.
Heres what i've done so far -
Any help would be appreciated.
can i get a bit of help with my H/W, the task is as follows:
Develop a program that analyses a sentence that contains several words without punctuation. When a word in that sentence is input, the program identifies all of the position the word occurs in the sentence. The system should not be case sensitive: Ask, ask & ASK should be treated as the same word.
For example, in the sentence ASK NOT WHAT YOUR COUNTRY CAN DO FOR YOU ASK WHAT YOU CAN DO FOR YOUR COUNTRY
The word ‘COUNTRY’ occurs in the 5th and 17th positions.
Analyse the requirements for this system and design, develop, test and evaluate a program to locate and return the position(s) of the word you have selected in a particular sentence or return an error message if the word is not in the sentence.
Heres what i've done so far -
sentence= input ("Enter a sentence that contains several words, without punctuation.") print(sentence) sentence.split(' ') word=input("please enter a word from the sentance and its position shall be displayed") if word in sentence: print ("found word") else: print ("word not found")My problem is that the code wont tell me the position of a word in the sentence and that the code is not case - insensitve.
Any help would be appreciated.