runtime
192 / 500
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.

Functionmost_expensive(path, n)
Filecolumns product_id,sku,name,category,list_price,discontinued_on; list_price may be empty
Returnsthe names of the n products with the highest price, highest first; fewer if there aren't n priced products
Tiesproducts 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']

Loading your progress…

Fix the price ranking — Python practice · Runtime