Top.Mail.Ru
Ответы

Программирование бота на питоне

Вот мне нужно что бы бот выдавал рандомную вразу red или blue. Но почему то оно выдает мне только red подскажите пожалуйста как исправить
вот код:
import telebot
import random


b = ['blue' , 'red']
tabletka = random.choice(b)
bot = telebot.TeleBot("(token)")

@bot.message_handler(commands=['start', 'help','main','hello'])
def main_(message):
bot.send_message(message.chat.id,"hello")
@bot.message_handler(commands=['blue_or_red'])
def blue_or_red(message):
bot.send_message(message.chat.id, tabletka)

bot.infinity_polling()

По дате
По рейтингу
Аватар пользователя
Мастер
8мес

import telebot
import random

bot = telebot.TeleBot("(token)")

@bot.message_handler(commands=['start', 'help', 'main', 'hello'])
def main_(message):
bot.send_message(message.chat.id, "hello")

@bot.message_handler(commands=['blue_or_red'])
def blue_or_red(message):
b = ['blue', 'red', 'green']
tabletka = random.choice(b)
bot.send_message(message.chat.id, tabletka)

bot.infinity_polling()