Answer the question
In order to leave comments, you need to log in
I am writing a bot chat game in a telegram in Python - number guessing, how to implement a condition?
Good afternoon, dear Geeks
Help me solve a problem in python, I'm still stupid in programming
The idea is such a telegram bot that plays "guess the number" without unnecessary details
The user enters a number - it is compared with a list in which the range is 1-99
And tells the user - "You are in range" or else "you are not in the range"
I want to solve the issue through the list. Although I agree with the other option.
allowable
list_numeros = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
92, 93, 94, 95, 96, 97, 98, 99]
start_g_markup = types.InlineKeyboardMarkup(row_width=2)
btn_START = types.InlineKeyboardButton('Начать ИГРУ', callback_data='start_game')
start_g_markup.add(btn_START)
@bot.message_handler(commands=['start', 'help'])
bot.reply_to(message, text="""ЗДЕСЬ ПРАВИЛА и тд Жми начать игру и все будет понятно!""", reply_markup=start_g_markup)
@bot.callback_query_handler(func=lambda call : True)
def cbdata(call) :
if call.data == "start_game" :
bot.send_message(call.message.chat.id, "Выбирай ЧИСЛО от 1 до 99")
@bot.message_from_user.id(content_type['text']) - но полагаю что должно быть не текст а int
def sravnenie(message)
if ##число = числу из списка list_numeros :
bot.reply_to(message, text="""ты в диапазоне 1-99""", reply_markup=start_g_markup)
elif ##число не равно числу из списка list_numeros :
bot.reply_to(message, text="""ты НЕ в диапазоне 1-99""", reply_markup=start_g_markup)
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