Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
"Bigger Price" solution in Uncategorized category for Bigger Price by Mateusz_Wryszcz
def bigger_price(limit: int, data: list[dict]) -> list[dict]:
"""
TOP most expensive goods
"""
sorted_data = sorted(data, key = lambda x: x["price"], reverse = True)
return sorted_data[:limit]
print("Example:")
print(
bigger_price(
2,
[
{"name": "bread", "price": 100},
{"name": "wine", "price": 138},
{"name": "meat", "price": 15},
{"name": "water", "price": 1},
],
)
)
assert bigger_price(
2,
[
{"name": "bread", "price": 100},
{"name": "wine", "price": 138},
{"name": "meat", "price": 15},
{"name": "water", "price": 1},
],
) == [{"name": "wine", "price": 138}, {"name": "bread", "price": 100}]
assert bigger_price(
1, [{"name": "pen", "price": 5}, {"name": "whiteboard", "price": 170}]
) == [{"name": "whiteboard", "price": 170}]
print("The mission is done! Click 'Check Solution' to earn rewards!")
Dec. 30, 2022