On Jun 22, 1:46 am, Charles Sanders <[EMAIL PROTECTED]>
wrote:
> Paul Rubin wrote:
>
> > from itertools import izip
> > pos = map(dict(izip(l2, count())).__getitem__, l1)
>
> or probably less efficiently ...
>
>  >>> l1 = [ 'abc', 'ghi', 'mno' ]
>  >>> l2 = [ 'abc', 'def', 'ghi', 'jkl', 'mno', 'pqr']
>  >>> pos = [ l2.index(i) for i in l1 ]
>  >>> print pos
> [0, 2, 4]
>
> Charles

Hey Guys thanks for the feedback and the suggestions.
Charles I got your implementation to work so many thanks for this.

this is what I had so far

for spam in l1:
        for eggs in l2:
                if spam == eggs:
                        print "kaka", spam, eggs

so its almost working just need the index, I'll
continue playing with the nested loop approach for a bit more.

Thanks once again guys

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to