S
S
shuzzixd2021-07-13 21:43:13
Python
shuzzixd, 2021-07-13 21:43:13

How to fix list index out of range error?

@bot.message_handler(content_types=['text'])
def handle_text(message):
    with sqlite3.connect('ref.db') as conn:
        cur = conn.cursor()
        cur.execute("SELECT `ban` FROM `users` WHERE id_user =?", (message.chat.id,))
        rows = cur.fetchall()
        if 'True' in rows[0]:
            bot.send_message(message.chat.id, 'Тебя забанили')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Gornostaev, 2021-07-13
@shuzzixd

Add a check that the selection from the database has a result.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question