Answer the question
In order to leave comments, you need to log in
Why is the variable not added to callback_data (aiogram)?
There is a list with the names of the courses, I create an inline keyboard and go through all the elements of the list below. At the same time, I add the current element to the inline keyboard and also callback_data which is also equal to the current element. The problem is that this same calbback_data causes an error if you pass exactly the variable containing the current list element. If you write just some line, everything is OK, but I need a specific variable. How to be?
courses = ['first', 'second', 'и тд.']
courses_keyboard = InlineKeyboardMarkup()
for course in courses:
courses_keyboard.add(InlineKeyboardButton(text=course, callback_data=course))
raise err(cls.text or description)
aiogram.utils.exceptions.ButtonDataInvalid: Button_data_invalid
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question