Answers for "get index from a list in python"

43

python find index by value

>>> ["foo", "bar", "baz"].index("bar")
1
Posted by: Guest on November-19-2019
5

how to find the position in a list python

lst = [4, 6, 5]
lst.index(6) # will return 1
Posted by: Guest on October-15-2020
0

python, list, index function

# vowels list
vowels = ['a', 'e', 'i', 'o', 'i', 'u']

# index of 'e' in vowels
index = vowels.index('e')
print('The index of e:', index)

# element 'i' is searched
# index of the first 'i' is returned
index = vowels.index('i')

print('The index of i:', index)
Posted by: Guest on September-28-2020

Code answers related to "get index from a list in python"

Python Answers by Framework

Browse Popular Code Answers by Language