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
?
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
?
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.