Suppose you want to find the index of an item in a list in Python. You can use the built-in
index() function to do so. The
index() function takes the item you want to search for as its first argument.
So the signature of the
index() function is as follows:
list.index(key [, start[, end]])
end arguments are optional actually. You use those to specify the range of the list you want to search. By default the
index() function searches the whole lists.
pizza_toppings = ['tomato sauce', 'cheese', 'tuna'] index = pizza_toppings.index('cheese') print(index) # => 1