-1

For example, lets say I have a list example=[A,B,C,D]

How do I return the value of the position? So for A, I would want a returned value of 0. B would be 1, C would be 2, D would be 3.

Molly
  • 19
  • 2
  • 1
    90% of the time, when you _think_ you want to do this, what you _actually_ wanted was to have a `dict` mapping values to numbers, not a `list` that you have to search through over and over. – abarnert May 23 '15 at 04:48
  • Do you just need the `index` positions like 0,1,2,3 ? or you want the elements of the `example` and the `index` ? I am not so sure if I understand what you want exactly. – Joe T. Boka May 23 '15 at 04:51

1 Answers1

1

you are looking for .index() of a list object

['a', 'b', 'c', 'd'].index('c') # 2
t3dodson
  • 3,949
  • 2
  • 29
  • 40