Dec-02-2019, 11:19 PM
It's looking for any sequence of "lav" in the string. Here are two solutions.
1. Split the sentence up by white space. This will change the sentence to a list which you can iterate over, checking for the word.
1. Split the sentence up by white space. This will change the sentence to a list which you can iterate over, checking for the word.
sentence = message.text.lower() if "lav" in sentence.split(): bot.send_message(message.chat.id, "Najgore pivo...")2. Use a regular expression instead. "\blav\b" will do the trick.
import re match_lav = re.compile("\blav\b") matches = match_lav.findall(message.text.lower()) if len(matches) > 0: bot.send_message(message.chat.id, "Najgore pivo...")