Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in Python by (16.4k points)

Let's say I have a list 

["foo", "bar", "baz"]

In python, How can I get the index of the "bar" element in the list?

1 Answer

0 votes
by (26.4k points)

You can use "index"

Look at the following code:

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

Output:
1
Want to know more information about python? Come and join: python training course

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...