R
R
rosty62021-11-01 23:38:52
Python
rosty6, 2021-11-01 23:38:52

How to send a random question from the ones already prepared for the telegram bot on Aiogram?

I am making a bot for Telegram in Python. I don't know how to do the following:
After clicking on the "Question" button in the bot, randomly send a question from the previously prepared questions.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Ushakov, 2021-11-02
@Nightmare1

# в методе обрабатывающем кнопку
import random

question = random.choice(QUESTIONS) # из списка (list) вопросов (текста) выдаёт один случайный вариант .

метод_отображения_кнопки (question) # Вывод случайного вопроса .

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question