Answer the question
In order to leave comments, you need to log in
How to make the bot ignore punctuation?
Let's say there is text
If msg.text.lower() == 'How to eat an apple?':
await msg.reply('Hands')
How to tell the bot that "?" sign and generally other symbols do not always need to be taken into account? Do not write the same command a second time, only without a question mark.
Please post the full result!
Answer the question
In order to leave comments, you need to log in
You can remove all specified characters from the list through str.translate
text = 'Как съесть яблоко?'
text = str.translate(text, str.maketrans('', '', '.,?:-;/\\'))
"execution cannot be pardoned"
well, now let's encourage the lack of punctuation, I think that in the future you will encounter big problems, but IMHO, if you decide to remove all punctuation marks, then just do replace () then you will be left with bare text without punctuation marks, the approach is controversial but has the right to life, I think, again, IMHO, in general, it’s up to you to decide how to be better, but you can ask how many such examples you have, that is, how many such cases appear in dialogues, it’s one thing when there are 5-10 percent of them and another thing when there are 90 of them, but anyway, I would not encourage this IMHO
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question