import re
while True:
* * sentence = input("Enter a sentence: ")
* * if not re.match("^[a-zA-Z ]*$", sentence):
* * * * print("Error! Only letters a-z allowed!")
* * else:
* * * * sentence.split()
* * * * break
splitsentence = sentence.split()
word = input("Enter a word from your sentence.")
if word in splitsentence:
* * print("The word:",word, "is located on word number(s):", splitsentence.index(word))
else:
* * print("Error! Word not found in your sentence.")
import re
while True:
* * sentence = input("Enter a sentence: ")
* * if not re.match("^[a-zA-Z ]*$", sentence):
* * * * print("Error! Only letters a-z allowed!")
* * else:
* * * * sentence.split()
* * * * break
splitsentence = sentence.split()
word = input("Enter a word from your sentence.")
if word in splitsentence:
* * print("The word:",word, "is located on word number(s):", splitsentence.index(word))
else:
* * print("Error! Word not found in your sentence.")
Copyright © 2024, NextGenUpdate.
All Rights Reserved.