i am trying to make this calculator work but it automatically sends a message please provide a valid number when i run the command /multiply any help would be muchly appreciated
type here
import telebot
bot = telebot.TeleBot('my token ')
first_number = None
second_number = None
@bot.message_handler(commands=['multiply'])
def multiply(message):
global first_number
global second_number
if first_number is None:
try:
first_number = int(message.text)
bot.send_message(message.chat.id, 'Please provide the second number')
except ValueError:
bot.send_message(message.chat.id, 'Please provide a valid number')
elif second_number is None:
try:
second_number = int(message.text)
result = first_number * second_number
bot.send_message(message.chat.id, 'Result: {}'.format(result))
first_number = None
second_number = None
except ValueError:
bot.send_message(message.chat.id, 'Please provide a valid number')
bot.polling()
i am trying to make it work