F
flamesrock
Kind of a fun but confusing problem...
I have two lists. Each list contains elements of two-element lists.
l1 = [['c1',1],['c2',2],['c3',4]]
l2 = [['c1',1],['c2',2],['c4',4],['c3',3]]
Exactly in this format, where
superlist[0][0] is always a string
superlist[0][1] is always an integer
Now what I would like to do is find the intersect of those two
super-lists based on superlist[0][0] and then compare the integers to
find ultimately:
A list of strings of the intersect of l1/l2, where the l1[x][1] >
l2[x][1]
In the case of the above example, that would be simply:
['c3']
But since lists are unhashable, I can't make a set consisting of
lists... Maybe I am making this problem too difficult by thinking in
terms of sets. Does anyone have a simple solution????
-Thanks
I have two lists. Each list contains elements of two-element lists.
l1 = [['c1',1],['c2',2],['c3',4]]
l2 = [['c1',1],['c2',2],['c4',4],['c3',3]]
Exactly in this format, where
superlist[0][0] is always a string
superlist[0][1] is always an integer
Now what I would like to do is find the intersect of those two
super-lists based on superlist[0][0] and then compare the integers to
find ultimately:
A list of strings of the intersect of l1/l2, where the l1[x][1] >
l2[x][1]
In the case of the above example, that would be simply:
['c3']
But since lists are unhashable, I can't make a set consisting of
lists... Maybe I am making this problem too difficult by thinking in
terms of sets. Does anyone have a simple solution????
-Thanks