Keyboard shortcuts

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

in list

  • in

Check if the value is in the list?

words = ['apple', 'banana', 'peach', '42']
if 'apple' in words:
    print('found apple')

if 'a' in words:
    print('found a')
else:
    print('NOT found a')

if 42 in words:
    print('found 42')
else:
    print('NOT found 42')

# found apple
# NOT found a
# NOT found 42