Finding the index of an item given a list containing it in Python -


for list ["foo", "bar", "baz"] , item in list "bar", what's cleanest way index (1) in python?

>>> ["foo", "bar", "baz"].index("bar") 1 

reference: data structures > more on lists


Comments

Popular posts from this blog

php - Auto increment employee ID -

php - isset function not working properly -

python - Evaluating the next line in a For Loop while in the current iteration -