0 works

Getting the index of an item in a list containing it in Python


dashboard+ Project

Posted by @bravocoder #python

Code snippet:

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

More details:

Example: For a list ["foo", "bar", "baz"] and an item in the list "bar", how to get its index (1) in Python.

Code snippet source:

https://stackoverflow.com/questions/1602934/check-if-a-given-key-already-exists-in-a-dictionary

>> Browse more code snippets

more_vert