как сделать вывод курса валют одним сообщением?
При ответе сообщений курс валют по каждой валюте отправляется отдельным сообщением , как сделать отправку одним сообщением?
for node in elements:
for child in node.childNodes:
if child.nodeType == 1:
if child.tagName == 'Value':
if child.firstChild.nodeType == 3:
value = float(child.firstChild.data.replace(',', '.'))
if child.tagName == 'CharCode':
if child.firstChild.nodeType == 3:
char_code = child.firstChild.data
if char_code == "USD" or char_code == "EUR" or char_code == "PLN" or char_code == "UAH":
currency_dict[char_code] = value
return currency_dict
def print_dict(dict):
for key in dict.keys():
bot.send_message(message.chat.id, f"{key} = {dict[key]}")
Ответы (2 шт):
Автор решения: Exord
→ Ссылка
def print_dict(dict):
bot.send_message(message.chat.id, '\n'.join([f'{key} : {value}' for key, value in dict.items()]))
Автор решения: Сергей
→ Ссылка
Так можете попробовать:
def print_dict(dict):
bot.send_message(message.chat.id, str(list(dict.values()))