Re: common elements between list of lists and lists
On Jul 17, 4:30 pm, antar2 <[EMAIL PROTECTED]> wrote: > Hello, > > I am a beginner in python. > following program prints the second element in list of lists 4 for the > first elements in list 4 that are common with the elements in list 5 > > list4 = [['1', 'a'],['4', 'd'],['8', 'g']] > list5 = ['1'
Re: common elements between list of lists and lists
>>> list4 = [['1', 'a'],['4', 'd'],['8', 'g']] >>> list5 = [1, 2, 3] >>> set5 = set(list5) >>> [x for n, x in list4 if int(n) in set5] ['a'] -- http://mail.python.org/mailman/listinfo/python-list