Where is the element in the list
- index
words = ['cat', 'dog', 'snake', 'camel']
print(words.index('snake'))
print(words.index('python'))
Output:
2
Traceback (most recent call last):
File "examples/lists/index.py", line 6, in <module>
print(words.index('python'))
ValueError: 'python' is not in list