Index improved
- index
words = ['cat', 'dog', 'snake', 'camel']
name = 'snake'
if name in words:
print(words.index(name))
name = 'python'
if name in words:
print(words.index(name))
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
words = ['cat', 'dog', 'snake', 'camel']
name = 'snake'
if name in words:
print(words.index(name))
name = 'python'
if name in words:
print(words.index(name))