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")

Edited 10 Months Ago by nic56208

This article has been dead for over six months. Start a new discussion instead.