[Tutor] comparison function/built-in needed

joe_schmoe geek_show at dsl.pipex.com
Wed Apr 6 20:17:27 CEST 2005


Greetings

I am attempting to compare the items in two lists across two criteria - 
membership and position. For example:

list_a = [ 0, 4, 3, 6, 8 ]
list_b = [ 1, 8, 4, 6, 2 ]

Membership = There are 3 items that are common to both lists, that is 3 
items in list_a have membership in list_b (viz: 4, 6, 8);
Position = There is 1 item in list_a that is also in the same position 
in both lists (viz: 6).

I have been playing around with for loops and iterations, but feel 
convinced that someone must have tackled this issue previously and who 
knows maybe even wrote a module/built-in that will do the trick.

I'm using Python-2.4.1

Thanks for any insights

/j


More information about the Tutor mailing list