Rita Sue and Bob too

Lo?c Mah? loic.mahe at free.fr
Fri Aug 20 11:49:50 EDT 2004


Hello

You can do it with list List Comprehensions:

BigList = ['Jean', 'Eric', 'Remy', 'Anne', 'Denis', 'Alain', 'Armel',
'Louis']
SmallList = ['Eric', 'Denis', 'Georges', 'Jean']

if ( [x for x in SmallList if x in BigList] == SmallList ):
   print "They were found"
else:
   print "They are not in list"


[x for x in SmallList if x in BigList] evaluates to a list with common
elements of SmallList and BigList


Loïc



More information about the Python-list mailing list