Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
MySolutionBiggerPrice solution in Clear category for Bigger Price by jemg2030
def bigger_price(limit: int, data: list[dict]) -> list[dict]:
"""
TOP most expensive goods
"""
# your code here
return sorted(data, key=lambda x: x['price'], reverse=True)[: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!")
March 7, 2023
Comments: