1
私はPythonには新しく、このプログラムで句読点を無視させる方法がわかりません。私はそれが本当に非効率であることを知っていますが、私は今この時点でそれについて気にしません。このプログラムで句読点を無視させるにはどうすればいいですか
while True:
y="y"
n="n"
Sentence=input("Please enter your sentence: ").upper()
print("Your sentence is:",Sentence)
Correct=input("Is your sentence correct? y/n ")
if Correct==n:
break
elif Correct==y:
Location=0
SplitSentence = Sentence.split(" ")
for word in SplitSentence:
locals()[word] = Location
Location+=1
print("")
FindWord=input("What word would you like to search? ").upper()
if FindWord not in SplitSentence:
print("Your chosen word is not in your sentence")
else:
iterate=0
WordBank=[]
for word in SplitSentence:
iterate=iterate+1
if word == FindWord:
WordBank.append(iterate)
print(FindWord, WordBank)
break
私はあなたが句読点のためのテストを支援するために、Pythonのstring
モジュールを使用することができますあなたが私に
あなたはa-zA-Z0-9以外のものを取り除きたいだけですか、またはテストする句読点を設定していますか? – Fallenreaper