comparing two lists and returning "position"

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Fri Jun 22 02:18:12 EDT 2007


On Fri, 22 Jun 2007 03:11:16 +0000, hiro wrote:

> Hi there, I have a 2 lists.. for simplicities sake lets say the are:
> 
> l1 = [ 'abc' 'ghi' 'mno' ]
> 
> l2 = [ 'abc' 'def' 'ghi' 'jkl 'mno' 'pqr']
> 
> what I need to do is compare l1 against l2 and return the "position" of
> where each object in l1 is in l2
> 
> ie: pos = 0, 2, 4


Thanks for sharing. Did you have a question, or did you just want to tell 
us what you were doing?



> Thanks in advance, -h

My pleasure.


-- 
Steven.



More information about the Python-list mailing list