Topic starter 18/06/2021 1:22 pm
Given a list ["foo", "bar", "baz"]
and an item in the list "bar"
, how do I get its index of item "bar" in Python?
Govind and myTechMint liked
27/06/2021 4:39 pm
You can achieve this by using index()
["foo", "bar", "baz"].index("bar")
Output:
1
Reference: Data Structures > More on Lists