My code is to find what position a word occurs in a list and I need it to not accept numbers as an input.
sentence = input("What is your sentence? ")
List1 = sentence.split(' ')
List1 = [item.lower() for item in List1]
word = input("What word do you want to find? ")
word = word.lower()
length = len(List1)
counter = 0
while counter < length:
if word == List1[counter]:
print("Word Found In Position ",counter)
counter += 1
elif word != List1[counter]:
counter += 1
else:
print("That word is not in the sentence")
This is my current code. However, it still accepts numbers. I know that it is a similar question here: Asking the user for input until they give a valid response but I need it to fit with my existing code and I don't know how.