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?
Use Markdowns (V2) 'pre-formatted fixed-width code block' to preserve the alignment. [Docs]
Wrap the wonderfully aligned table in a code-block using 3 back-ticks (```)
```
one          1
two          2
three        3
```
Send your message with the parse_mode option set to: MarkDown (V2)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With