You are viewing a single comment's thread from:
RE: Payment for Coding done
Function to calculate average flight price for a destination
def calculate_average_price(flight_data, destination):
prices = [flight["price"] for flight in flight_data if flight["destination"] == destination]
if not prices:
return None
return sum(prices) / len(prices)