I don't understand why the print function is printing the expected output But the return, returns None...
This my function
#json search function:
def searchfunction(searches,query,myresults,i = 0):
print('i:',i,'nr of searches',len(searches),'nr results:',len(myresults))
newresults = []
if i <= len(searches)-1:
for item in myresults:
for key in item:
if key == searches[i]:
#print(key, item[key],query.split(','))
if item[key] in query.split(','):
#print(key, item[key], query.split(','))
newresults.append(item)
i += 1
myresults = newresults
tmp = searchfunction(searches, query, myresults, i)
else:
print('print result:',myresults)
return myresults
Using the function:
searches = ["Product featured","Master Messaging","Phase","length","Asset 1"]
query = "ipl5,Female 25+,catch,6,copy_press-play"
searchresults = searchfunction(searches, query, results)
print('result?',searchresults)
Output:
i: 0 nr of searches 5 nr results: 448
i: 1 nr of searches 5 nr results: 132
i: 2 nr of searches 5 nr results: 66
i: 3 nr of searches 5 nr results: 18
i: 4 nr of searches 5 nr results: 9
i: 5 nr of searches 5 nr results: 1
print result: [{'id': '4', 'label': 'GFX_watching-tv-netflix_ipl5_Female 25+_catch_6', 'Base name': 'watching-tv-netflix', 'Product featured': 'ipl5', 'Master Messaging': 'Female 25+', 'Phase': 'catch', 'length': '6', 'Asset 1': 'copy_press-play', 'options overrides': '', 'Asset 2': 'copy_on-smooth-skin', 'Asset 3': 'endcard_long-lasting-smooth-skin-your-way', 'Asset 4': ''}]
#???
result? None
Tried a lot of variations but no luck...