附:
sentence= input("Enter a sentence")
keyword= input("Input a keyword from the sentence")
Run Code Online (Sandbox Code Playgroud)
我想在句子中找到关键字的位置.到目前为止,我有这个代码摆脱标点符号并使所有字母小写:
punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~'''#This code defines punctuation
#This code removes the punctuation
no_punct = ""
for char in sentence:
if char not in punctuations:
no_punct = no_punct + char
no_punct1 =(str.lower (no_punct)
Run Code Online (Sandbox Code Playgroud)
我知道需要一段实际找到该单词位置的代码.