Hi this is my code for Telegram bot,I have a list that fills by names.
the bot add usernames to list and reply it as a list
I want to reply every name in seperate lines
list = []
txt = str(list)
def msg_filter(bot , update):
wordsp = ["man"," miam"]
wordsn = ['nemiam','nistam','na']
if len(list) <=15:
if any (i in update.message.text for i in wordsp):
if "{}".format(update.message.from_user.first_name) not in list:
list.append("{}".format(update.message.from_user.first_name))
bot.send_message(chat_id = update.message.chat_id , text = "{}".format(list))
I have this in output : ['username1','username2','username3']
but expect this:
4
Answers
text=”[{}]”.format(“n”.join(lst))
If you want to output the list new-line separated you can use #join and use the newline-character (
n
) as separator for your list entries.For example:
which will output:
If you explicitly want the
[
&]
outputed as well, you can use format to add them:you could use:
If you need exact this result without any quotes:
Try this simple solution:
where list_ = [‘username1′,’username2′,’username3’]