I have two lists: one contains the products and the other one contains their associated prices. The lists can contain an undefined number of products. An example of the lists would be something like:
- Products : ['Apple', 'Apple', 'Apple', 'Orange', 'Banana', 'Banana', 'Peach', 'Pineapple', 'Pineapple']
- Prices: ['1.00', '2.00', '1.50', '3.00', '0.50', '1.50', '2.00', '1.00', '1.00']
I want to be able to remove all the duplicates from the products list and keep only the cheapest price associated with the unique products in the price list. Note that some products might have the same price (in our example the Pineapple).
The desired final lists would be something like:
- Products : ['Apple', 'Orange', 'Banana', 'Peach', 'Pineapple']
- Prices: ['1.00', '3.00', '0.50', '2.00', '1.00']
I would like to know the most effective way to do so in Python. Thank you