
from django.utils.translation import gettext_lazy as _

  
def find_least_price(prices: list, key_name: str = None) -> float:

    if not prices:
        raise ValueError("Input array of prices cannot be empty.")

    if key_name:

        return min(prices, key=lambda item: item['price'])
    else:
        return min(prices)