-1

In Python if you have a list:

list = [ cow , dog , cat ]

Is it possible to find what index an element is at?

Is there a command which does something like:

{some code}(cow)

and have it say something like cow = 0?

jscs
  • 63,694
  • 13
  • 151
  • 195

1 Answers1

7

Of course there is. Try

>>> ['cow', 'dog', 'cat'].index('cow')
0

May i suggest, don't use list as a variable name, as it is already used for constructing a list object.

VHarisop
  • 2,816
  • 1
  • 14
  • 28