Demo entry 6235162

defValidation(StrToValid):if(StrToValid=="")or(StrToValid==" "):# fails the presence checkprint(" Error! Nothing has been input. Please enter a sentence.")returnFalse# punctuation presence checkPunctuations="!'£$%^&*()_+=~#{}[]:;@<>,.?/|\""# created a list of punctuationforPuncCharinPunctuations:ifPuncCharinStrToValid:# find whether there is Punctuations in UserSentprint(" Error! There are punctuations in the sentence. ")returnFalsereturnTrue# when it goes to here, it is valid# Prodedure to check whether there is a space to determine is a word or sentencedefSpaceCheck(StrToValid):globalSpacing# making "Spacing" available outside the module# counting whitespace in StrToValid NumWhitespace=StrToValid.count(" ")if(NumWhitespace<1):Spacing="word"print(" This is word. ")print()else:Spacing="sentence"print(" This is a sentence. ")print()# Splash:print(" This is A453 Task 1 - search a word's position in a sentence. ")print(" By Wu Sze Lam Christy - 7069")print()# Get inputs with validation:IsValid=False# boolean for validationwhilenotIsValid:UserSent=input(" Please enter a SENTENCE without any punctuation: ")ifnotValidation(UserSent):print(" Please try again. ")print()else:SpaceCheck(UserSent)ifSpacing=="word":print(" Please try again. ")print()else:IsValid=TrueIsValid=False# boolean for validationwhilenotIsValid:UserWord=input(" Please enter a WORD without any punctuation: ")ifnotValidation(UserWord):print(" Please try again. ")print()else:SpaceCheck(UserWord)ifSpacing=="sentence":print(" Please try again. ")print()else:IsValid=True# Capitalise the inputs:UserSent=UserSent.upper()# http://www.tutorialspoint.com/python/string_upper.htmUserWord=UserWord.upper()# Confirm what the user had entered:print(" Your sentence: %s "%UserSent)print(" Your word to search is: %s"%UserWord)print()# split the sentence into individual words:ListOfWord=UserSent.split(" ")# split the sentence into a list of words by whitespaceprint("There are:")Seperator=", "print(Seperator.join(ListOfWord))print("in your sentence.")print()IsFound=FalseforWordNuminrange(len(ListOfWord)):# go through word by wordWordSent=ListOfWord[WordNum]ifWordSent==UserWord:# when there is a matchIsFound=Trueprint(" Word poition: ",(WordNum+1))# Checked all wordsifIsFound==False:# word is not found after all words matched once print(" The word is not found. ")# error message when word is not in sentenceinput()# pause for any key - test purpose