I'm trying to create a simple Telegram Bot using the python-telegram-bot library, but i can't align a dictionary with the default "{0:<20} {1}".format(key, value)
idea.
Let me give u an example:
Mapy = {
"one": "1",
"two": "2",
"three": "3",
"four": "4",
"five": "5",
"six": "6",
"seven": "7",
"eight": "8"
}
tmpstring = ""
for key, value in Mapy.items():
tmpstring = tmpstring + "{0:<20} {1}".format(key, value) + "\n"
print(tmpstring)
context.bot.send_message(chat_id=update.message.chat_id, text=tmpstring)
the printed finish looks like this:
one 1
two 2
three 3
four 4
five 5
six 6
seven 7
eight 8
as expected nicely aligned, but the message in Telegram looks like this:
So my question is: How can i align the chat message so it looks like the printed output?
"```"
and usingparse_mode="Markdown"
in thesend_message
fixed my problem. – Elaelaborate