List of lists
Denis S. Otkidach
ods at strana.ru
Wed Nov 19 07:13:38 EST 2003
More information about the Python-list mailing list
Wed Nov 19 07:13:38 EST 2003
- Previous message (by thread): List of lists
- Next message (by thread): List of lists
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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]
- Previous message (by thread): List of lists
- Next message (by thread): List of lists
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list