[Tutor] Location of found item in list.

John Fouhy john at fouhy.net
Thu Oct 19 02:37:33 CEST 2006


On 19/10/06, Chris Hengge <pyro9219 at gmail.com> wrote:
> What that should have said
>
> For clarification if I didn't provide enough earlier,
> for item in list1:
>     if item in list2:
>          print item and list2[object that matched item] <-- need this
> location.

Um, I'm still a bit confused.

Suppose item == list2[10].  Does that mean you want to print item and list2[10]?

Won't that just mean you print item twice?

You can find the position of an element in a list by using the
list.index() method, but I'm still not sure exactly what you're trying
to do here.

-- 
John.


More information about the Tutor mailing list