Python List index() is time-consuming

耗时非常多的函数

When I do a homework in a online course, I found that a method List.index() is time-consuming.

This is how the index() method is normally used:

animals = ['cat', 'dog', 'rabbit', 'horse']
# get the index of 'dog'
index = animals.index('dog')

print(index)

# Output: 1