Skip to content

Instantly share code, notes, and snippets.

@zkan
Last active January 19, 2021 05:02
Show Gist options
  • Save zkan/9a995df13e223bd5cb69a1443d0447eb to your computer and use it in GitHub Desktop.
Save zkan/9a995df13e223bd5cb69a1443d0447eb to your computer and use it in GitHub Desktop.
Check if multiple strings exist in another string
key = 'process-id and depapi-endpoint'
def check1(key):
if 'process-id' in key or 'source-path' in key or 'depapi-endpoint' in key:
return True
def check2(key):
matches = [
'process-id',
'source-path',
'deapi-endpoint',
]
if any(item in key for item in matches):
return True
assert check1(key) == check2(key)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment