How To Build A Function That Returns Elements Matching In Txt. File And Dictionary
I am new to Python, so apologies in advance if my question seems foolish. I am trying to build a function that searches for keys and values of a nested dictionary (built from info
Solution 1:
Your script is returning the key of the dictionary, and you want the values.
Substitute this:
if any([str(term_variations[term]) in i for i in document]):
Wherever you have "term" replace it with term_variations[term].
It's worth noting, that your logic matches '0095', in your example data, with 'da#8970095-v4' in your "text" list.
2nd part of question:
For starters, if Hong Kong Co is your client lookup, then this line of code: client_summary = ['Client: ' + str(term_tracker(text, clientlist[clientname]['Client Code']))]
is passing term_tracker(text,'897') into your function, which will return the empty list from term_tracker(). Which will then write nothing to your file.
Post a Comment for "How To Build A Function That Returns Elements Matching In Txt. File And Dictionary"