I have a recursive traversal function to go through a JSON object and return the information that I want. The problem is that it's not returning anything. I know that the recursion is working properly because I modified to function to print out the input at each step and it was printing out the expected results - including the final step.
def wikipedia_JSON_traversal(wiki):
if type(wiki)==dict:
if 'definitions' in wiki.keys():
wikipedia_JSON_traversal(wiki['definitions'])
elif 'text' in wiki.keys():
wikipedia_JSON_traversal(wiki['text'])
else:
pass
elif type(wiki)==list:
wikipedia_JSON_traversal(wiki[0])
else:
return wiki
returnstatement anywhere in theifblock.