V
V
Vladislav2022-02-20 16:53:27
Bots
Vladislav, 2022-02-20 16:53:27

How to display in one message, for example, 5 different words from one list so that they do not repeat?

Is it possible?
I'm making a bot on Telebot.

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Dedinets, 2022-02-20
@donko1

Try it:

l = ['hello', 'hello', 'world', 'foo', 'foo', 'bar']# Этот список дан для теста
out = []
for i, elem in set(l):
    if i >= 5: # Вместо пяти ваше число
        out.append(elem)
bot.send_message(message.from_user.id, *out)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question