I'm making a program that identifies the word position in a sentence.

For example, in the sentence
ASK NOT WHAT YOUR COUNTRY CAN DO FOR YOU ASK WHAT YOU CAN DO FOR YOUR COUNTRY

The word 'COUNRTY' appears in the 5th and 17th positions.

This is what I have so far. Any ideas for what I can add on please?

varSentence =  input("Enter the sentence")

print (varSentence)

varWord = input("Enter word ")

import time
time.sleep(1)
print('Please wait')

varSplit = varSentence.split()

import time
time.sleep(1)
if varWord in varSplit:


        print ("Found word")


else:
    print ("Error word not found.Try again")

Hint: type help(str.find) in a python console. You can also try help(str.index) !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.