Skip to content

Instantly share code, notes, and snippets.

@ogra
Created March 26, 2012 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ogra/2204403 to your computer and use it in GitHub Desktop.
Save ogra/2204403 to your computer and use it in GitHub Desktop.
returns if any elements in example_list are in example_string.
# the following code returns if any elements in example_list are in example_string.
True in [x in example_string for x in example_list]
# example: 'a' is in 'apple', so True is returned.
# >>> example_list = ['a', 'b', 'c']
# >>> example_string = 'apple'
# >>> True in [x in example_string for x in example_list]
# True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment