list comprehention
Paddy
paddy3118 at netscape.net
Tue Jan 24 13:53:08 EST 2006
Umm,
My answer is not correct, but for a different reason; it seems you need
the length of my
previous answer, thus:
PythonWin 2.4 (#60, Feb 9 2005, 19:03:27) [MSC v.1310 32 bit (Intel)]
on win32.
Portions Copyright 1994-2004 Mark Hammond (mhammond at skippinet.com.au) -
see 'Help/About PythonWin' for further copyright information.
>>> ref = [3, 3, 1, 1, 3]
>>> lst=[5, 1, 4, 5, 3]
>>> answer = len([ val for val in set(ref) for x in range(min(lst.count(val), ref.count(val)))])
>>> answer
2
>>>
- Paddy.
More information about the Python-list
mailing list