I'm trying to update a list of lists within a dictionary where I would like to remove any list (within the list of lists) that has an item that is smaller than whatever I'm comparing it with. For example, given the dict of list of lists below..
mydict = {3603172: [
['M2-HCg18', 12.00, 12.00, 9.00, '12 x 12 x 9'],
['M2-HCg18', 16.00, 14.00, 8.00, '16 x 14 x 8'],
['M2-HCg18', 16.00, 14.00, 14.00, '16 x 14 x 14'],
['M2-HCg18', 18.00, 18.00, 18.00, '18 x 18 x 18'],
['M2-HCg18', 16.00, 10.25, 0.25, 'Bubble Mailer #5 10.5 x 16'],
['M2-HCg18', 7.25, 4.75, 1.00, 'Bubble Mailer #4 7.25 x 5'],
['M2-HCg18', 9.25, 7.25, 1.00, 'Bubble Mailer DVD 10.25 x 7.25'],
['M2-HCg18', 28.00, 14.00, 8.00, '28x14x8'],
['M2-HCg18', 28.00, 14.00, 0.25, '28x14x4'],
['M2-HCg18', 16.00, 10.25, 0.25, 'Bubble Mailer #5 10.5 x 16'],
]}
The above dict has a key (3603172) whose value is a list of lists. Note that there may be duplicate lists within the list of lists. What I'd like to do is compare the 4th item in any one of those inner lists with a given value and remove the list if the 3rd item in the list is smaller. So if my value is 0.5, I'd like to remove all the inner lists that are less than 0.5 at index 3.
I know that I can use mydict.itervalues() and operate on the value which is the list of lists and then run a compare on index 3 using an if statement with 0.5 but I don't really know a clean way of removing the list if the value at index 3 is smaller than 0.5. In the example above, I'd like to remove all lists with 0.25 at index 3 (smaller than 0.5). What would be a good way to do this?