question 192 CSV JSON & JSONL · easy
Fix the price ranking
most_expensive should return the names of the n priciest products, but on the catalogue it says the most expensive product is the £9.50 Breakfast Tea. Fix it. Products whose list_price is empty (no longer sold) must be left out.
Function
most_expensive(path, n)Filecolumns
product_id,sku,name,category,list_price,discontinued_on; list_price may be emptyReturnsthe names of the
n products with the highest price, highest first; fewer if there aren't n priced productsTiesproducts with the same price keep their file order
Examples
callmost_expensive('products.csv', 3)returns['Speaker, Organic', 'Ultra Pillow', 'Deluxe Pillow']
callmost_expensive('products.csv', 1)returns['Speaker, Organic']