I am trying to compare a list of words to a dictionary to see if there are any matches. How do I do this, as diction.has_key() does not work for lists?
cheechand
0
Newbie Poster
Recommended Answers
Jump to PostOne way ...
d = {'Jim': 19, 'Slim': 45, 'Peter': 23, 'Joe': 30, 'Mark': 27} q = ['Frank', 'Hank', 'Joe', 'Luke', 'Paul'] for key in d.keys(): if key in q: print key
All 2 Replies
Reply to this topic
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.