Answer the question
In order to leave comments, you need to log in
How to modify the code of a telegram bot written in aiogram?
Guys, please help to finalize the code.
If a person writes /random a1936, for example,
then there will be an error in the console, but how to make the bot send the user to write only numbers
Here is the code:
@dp.message_handler(commands=['random'])
async def rang(message: types.Message):
random6 = int(message.text.split()[1])
if random6 <= 10:
random_number = random.randint(0, random6)
await message.answer(f' Выпало случайное число из [0, {random6}] выпало на число {random_number}')
elif random6 >= 10:
await message.answer(f' Введите число меньше 10')
else:
await message.answer(f' ошибка')
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