Skip to content

Instantly share code, notes, and snippets.

@reox
Last active August 29, 2015 14:07
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 reox/d160d1ce8f5a739315b1 to your computer and use it in GitHub Desktop.
Save reox/d160d1ce8f5a739315b1 to your computer and use it in GitHub Desktop.
Check if string starts with multiple substrings
words = ["foo", "bar", "blafoo"]
check_list = lambda x, y: map(lambda z: not x.startswith(z), y)
if not all(check_list("foobarfoo", words)):
print("String starts with one of the substrings")
else:
print("String does not start with one of the substrings")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment