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

PHOTO EMBED

Saved by @bravocoder #python

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

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

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