A
A
artgin2021-09-26 17:12:07
Python
artgin, 2021-09-26 17:12:07

Python (aiogram): How to insert a parsed list into inline buttons?

I am writing a small parser bot for telegrams, because complete zero, I ran into a problem, I just can’t insert the parsed list, or rather each line into a separate inline button, i.e. 10 lines = 10 inline buttons... How can I organize this?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
SashaN69, 2021-09-26
@artgin

l = ['Яблоко', 'Груша']
keyboard = types.InlineKeyboardMarkup()
backbutton = types.InlineKeyboardButton(text="Back", callback_data="MainMenu")
button_list = [types.InlineKeyboardButton(text=x, callback_data=x) for x in l]
keyboard.add(*button_list, backbutton

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question