Skip to content

Instantly share code, notes, and snippets.

@FlamptX
Created June 3, 2021 12:01
Show Gist options
  • Save FlamptX/3ed5ddeb32eba223ebeeaf55187a65c8 to your computer and use it in GitHub Desktop.
Save FlamptX/3ed5ddeb32eba223ebeeaf55187a65c8 to your computer and use it in GitHub Desktop.
def getRootProperty(source, needle):
returnable = list(source)
sequence = 0
for root in source.items():
for i, j in enumerate(str(root)):
try:
no_numbers = not str(root)[i - 1].isdigit() and not str(root)[i + 1].isdigit() and str(needle) not in root[0]
except IndexError:
no_numbers = True
if j == str(needle) and no_numbers:
print(str(root))
return returnable[sequence]
sequence += 1
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment