I have this code ⬇️ in a Telegram bot (whit telebot).
When I send /start it send a random element but It send always the same
v1 = "1111"
v2 = "ABCD"
v3 = "EFGH"
v4 = "XXXX"
v5 = "0000"
list = [v1, v2, v3, v4, v5]
abcd = random.choice(list)
@bot.message_handler(commands=['help', 'start'])
def send_welcome(message):
bot.reply_to(message, abcd)
How can I solve it?
2
Answers
You select a value only once. Replace
bot.reply_to(message, abcd)
withbot.reply_to(message, random.choice(list))
to get random result every time.You could use
I think it is better to use a smaller amount of variables and the variable name
list
is a built-in classalso check if you have a
random.seed()
in your code