Answer the question
In order to leave comments, you need to log in
Method to populate InlineKeyboardMarkup in a loop?
I'm trying to create a bot on the python-telegram-bot library, I can't create buttons in a loop:
if data == "7":
markup = InlineKeyboardMarkup(resize_keyboard=True)
for answer in answers:
button = InlineKeyboardButton(text=answer, callback_data=answer)
markap.row(button)
update.message.reply_text("Ваш вопрос:\n" + text_question[0], reply_markup=markup)
Answer the question
In order to leave comments, you need to log in
answers = ["A", "B", "C"]
elif data == "7":
for answer in answers:
keys.append(InlineKeyboardButton(text=answer, callback_data=answer))
print(answers)
markup = InlineKeyboardMarkup([keys], resize_keyboard=True)
query.message.reply_text("Ваш вопрос:\n" + text_question[0], reply_markup=markup)
mark u p = InlineKeyboardMarkup(resize_keyboard=True)
for answer in answers:
button = InlineKeyboardButton(text=answer, callback_data=answer)
mark a p.row(button)
update.message.reply_text("Your question:\n" + text_question [0], reply_markup=markup)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question