Rita Sue and Bob too
Shane Holloway (IEEE)
shane.holloway at ieee.org
Mon Aug 23 01:28:33 CEST 2004
> You can do it with list List Comprehensions:
> BigList = ['Jean', 'Eric', 'Remy', 'Anne', 'Denis', 'Alain', 'Armel',
> SmallList = ['Eric', 'Denis', 'Georges', 'Jean']
> if ( [x for x in SmallList if x in BigList] == SmallList ):
> print "They were found"
> 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
A little change:
Difference = [x for x in SmallList if x not in BigList]
if not Difference:
print "They were found"
print Difference, "were not found in the list"
More information about the Python-list