You are viewing a single comment's thread from:

RE: Payment for Coding done

in #codingfund10 months ago

Function to compare prices of multiple airlines on the same route

def compare_prices(airline_data, route):
# Filter flight data for the specified route
route_data = [flight for flight in airline_data if flight["route"] == route]

if not route_data:
    return "No data available for this route."
Sort:  

Create a dictionary to store airline prices

airline_prices = {}

Populate the airline_prices dictionary

for flight in route_data:
    airline = flight["airline"]
    price = flight["price"]
    if airline not in airline_prices:
        airline_prices[airline] = []
    airline_prices[airline].append(price)

Calculate the average price for each airline

average_prices = {}
for airline, prices in airline_prices.items():
    average_prices[airline] = sum(prices) / len(prices)

return average_prices

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.029
BTC 67477.32
ETH 3474.01
USDT 1.00
SBD 2.69