Skip to content

Instantly share code, notes, and snippets.

@tommyip
Last active November 2, 2016 21:14
Show Gist options
  • Save tommyip/acc3d7770c748201f9add52a316c50ae to your computer and use it in GitHub Desktop.
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]
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
@tommyip
Copy link
Author

tommyip commented Nov 2, 2016

Needed this for my Brainfuck interpreter!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment