E
E
EduUse2020-08-14 12:25:15
Python
EduUse, 2020-08-14 12:25:15

How to implement if or or in a bot?

I am writing a simple telegram bot

if message.text == "Дима":
        bot.send_message(message.from_user.id, "ок")
       else:   
        bot.send_message(message.from_user.id, "Ошибка")

After registering "or ..." any message receives the answer "ok"

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
ScriptKiddo, 2020-08-14
@EduUse

Wrong Correct
if message.text == 'Дима' or 'Вася':

if message.text == 'Дима' or message.text == 'Вася':

names  = ['Дима', 'Вася']
if message.text in names:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question