Last active
November 2, 2016 21:14
-
-
Save tommyip/acc3d7770c748201f9add52a316c50ae to your computer and use it in GitHub Desktop.
Check if element is in a non-uniform N-d Python list [Python]
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
def in_nD_list(search_list, key): | |
for element in search_list: | |
if isinstance(element, str): | |
if key in element: | |
break | |
else: | |
if in_nD_list(element, key): | |
break | |
else: | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Needed this for my Brainfuck interpreter!