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

Tim Golden mail at timgolden.me.uk
Thu Dec 8 16:33:27 CET 2011


On 08/12/2011 15:28, surya k wrote:
>
> 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 ??

help ([])

...
  index(...)
      L.index(value, [start, [stop]]) -> integer -- return first index 
of value.
      Raises ValueError if the value is not present.


TJG


More information about the Tutor mailing list