Last active
January 19, 2021 05:02
-
-
Save zkan/9a995df13e223bd5cb69a1443d0447eb to your computer and use it in GitHub Desktop.
Check if multiple strings exist in another string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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