List of lists
Denis S. Otkidach
ods at strana.ru
Wed Nov 19 07:13:38 EST 2003
On Wed, 19 Nov 2003, saoirse_79 wrote:
s> I was wondering if anyone knows a short way to do the
s> following..
s> I have 2 lists of list..eg
s> [('a','b','c'),('k','-','l'),('1','2','3')]
s> [('a','b','c'),('k','-','x'),('1','4','3')]
s>
s> I want to comapre the two lists of lists and count the number
s> of
s> times the sublists match. In the above example its 1
>>> l1 = [('a','b','c'),('k','-','l'),('1','2','3')]
>>> l2 = [('a','b','c'),('k','-','x'),('1','4','3')]
>>> len([1 for t1, t2 in zip(l1, l2) if t1==t2])
1
--
Denis S. Otkidach
http://www.python.ru/ [ru]
More information about the Python-list
mailing list