D
D
drop1s2022-02-15 22:48:19
Telegram
drop1s, 2022-02-15 22:48:19

How to rebuild the list?

I have a list like this [('681581215',), ('581082656',), ('1659779061',)].
How to send a message to all of them via telebot (the same)?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly, 2022-02-16
@qavitalii

ids =  [('681581215',), ('581082656',), ('1659779061',)]
for i in ids: 
   tb.send_message(i[0], message)

W
Web Dentist, 2022-02-16
@kgb_zor

ids = [('681581215',), ('581082656',), ('1659779061',)]
# Проверяем кортеж на длину, чтобы избежать IndexError
# Пакуем в сет, чтобы избежать дубликатов
ids_for_send = {idt[0] for idt in ids if len(id_) > 0}
for idx in ids_for_send: 
   tb.send_message(idx, message)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question