Answer the question
In order to leave comments, you need to log in
How to send information not in separate messages, but in one message in the Telegram bot?
I have a dictionary handler that sends the names of the nearest places from a dictionary based on the user's location.
def uz_shop_view(message: telebot.types.Message) -> None:
if message.location is not None:
lon: float = message.location.longitude
lat: float = message.location.latitude
distance: List[...] = []
for loc in STORES:
result: float = geodesic(
(loc['lons'], loc['lats']), (lon, lat)).meters
distance.append(result)
counter = len(distance)
while counter > 0:
i = distance.index(min(distance))
print(i)
distance[i] = 10 ** 100
counter -= 1
bot.send_message(message.chat.id, f' ' + '<b>'+STORES[i]['title']+'</b>' + '\n\n' + '<i>'+STORES[i]['address']+'</i>', parse_mode='html')
Answer the question
In order to leave comments, you need to log in
I already said in the last question how to do it. You don't want to have everything done for you, do you?
If the dictionary contains a list of the form
arr = ['one', 'two', 'tree']
print(arr) # Выведит весь словарь
['one', 'two', 'tree']
print(arr[0]) # первое значения словаря.
'one'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question