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 string

  • in

Check if a substring is in the string?

txt = "hello world"
if "wo" in txt:
    print('found wo')

if "x" in txt:
    print("found x")
else:
    print("NOT found x")
found wo
NOT found x