def get_cheapest_food_location(product_name):
data = {
"bread": [
{"location_name": "Budapest", "country": "HU", "price": 850, "currency": "HUF"},
{"location_name": "Szeged", "country": "HU", "price": 790, "currency": "HUF"},
{"location_name": "Debrecen", "country": "HU", "price": 900, "currency": "HUF"},
],
"rice": [
{"location_name": "Budapest", "country": "HU", "price": 1200, "currency": "HUF"},
{"location_name": "Pécs", "country": "HU", "price": 1100, "currency": "HUF"},
],
}
if product_name not in data:
print("Nincs találat vagy elérhető ár ehhez a termékhez.")
return
cheapest_location = min(data[product_name], key=lambda x: x["price"])
print(f"A(z) '{product_name}' a legolcsóbb helyen:")
print(f"Helyszín: {cheapest_location['location_name']}")
print(f"Ország: {cheapest_location['country']}")
print(f"Ár: {cheapest_location['price']} {cheapest_location['currency']}")
if __name__ == "__main__":
search_item = "bread"
get_cheapest_food_location(search_item)
-----------
Output:
A(z) 'bread' a legolcsóbb helyen:
Helyszín: Szeged
Ország: HU
Ár: 790 HUF
------------
Futtatás; https://onecompiler.com/python#draft-zge8
Nincsenek megjegyzések:
Megjegyzés küldése