I'm not sure if there is some library that handles this, or if recursion is the way to go. I am trying to write a recursion function, when I call it it always ends up returning False
. Any help appreciated.
item
starts out as a dict.
text
is a string to match.
def match(item, text):
if item == text:
return True
if type(item) == list:
for i in item:
match(i, text)
if type(item) == dict:
for i in item.values():
match(i text)
return False
I'm not quite grasping how to have it keep going when say the first item of a list is not a match.