[Tutor] how to find index of list with its value

bodsda at googlemail.com bodsda at googlemail.com
Thu Dec 8 16:36:04 CET 2011


>>>mylist = [1,2,3,4,1]
>>>mylist.index(1)
0

But note that this only shows the index for the first occurrence of the item.

Bodsda 

Sent from my BlackBerry® wireless device

-----Original Message-----
From: surya k <suryak at live.com>
Sender: tutor-bounces+bodsda=googlemail.com at python.org
Date: Thu, 8 Dec 2011 20:58:37 
To: Python Tutor<tutor at python.org>
Subject: [Tutor] how to find index of list with its value


Well, we all know to know the value when we have the index of a list. But how can we find it in the reverse way...
say a listl=[1,2,3,4]
l[0]=1.but how can I find its address with its value 1 ?? 		 	   		  
_______________________________________________
Tutor maillist  -  Tutor at python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


More information about the Tutor mailing list