Search code examples
pythonvariablesbotstelegramtelepot

How to put a variable in bot.sendMesage (python)


I'm creating a telegram bot with python and I can't find the way to make the output of a variable with bot.sendMessage. Can anyone help me please?

var = '123'
bot.sendMessage(chat_id, "The number is:"var)

Solution

  • This is a python syntax error. You are not concatenating. You can do this for example (but you can use also other ways to concatenate):

    var = '123'
    bot.sendMessage(chat_id, "The number is:{}".format(var))