A
A
AsyJAIZ2020-06-25 13:15:17
Python
AsyJAIZ, 2020-06-25 13:15:17

How to search for multiple words in a sentence?

Hello! I am writing a second bot based on pyTelegramBotApi (telebot), it should respond to stop words that can be set by the command, but the problem is that I need to somehow search for these words, and it would be logical to use the method message.text.lower().find([stopwords])with the template used 'word ', 'word', 'word', but this is not supported in the .find() function. How to search for multiple words in a sentence?

Thanks in advance

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Pankov, 2020-06-25
@trapwalker

It seems that even those who do not know how to program rushed to write bots. I hope this wave does not come to medicine.
Write your own function, where you pass the text and a set of words, and inside the loop, look for each one until you find the first one that comes across.

D
Dimonchik, 2020-06-25
@dimonchik2013

.find do like this

M
masb, 2020-06-25
@masb

Regular Expressions https://docs.python.org/3/library/re.html . Difficult, incomprehensible, but better than your crutch with bust.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question