私は入力文を分析して、ユーザーがその中の特定の単語を検索できるようにするためにこのコードを作成しました。しかし、私は入力文のすべての句読点が無視されるようにする方法を考え出すことはできません。 「そこに友人」という文が入力された場合、そこに「そこ」という単語が「そこ」と数えられているので、ユーザーが「そこ」を検索している場合、それは文にはない。私を助けてください。私はPythonには本当に新しいです。このコードを作成するには、文章のすべての句読点を無視しますか?
print("Please enter a sentence")
sentence=input()
lowersen=(sentence.lower())
print(lowersen)
splitlowersen=(lowersen.split())
print (splitlowersen)
print("Enter word")
word=input()
lword=(word.lower())
if lword in splitlowersen:
print(lword, "is in sentence")
for i, j in enumerate (splitlowersen):
if j==lword:
print(""+lword+"","is in position", i+1)
if lword not in splitlowersen:
print (lword, "is not in sentence")
ありがとうございました! –