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

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -