dictionary_one = [ {'costume':'slutty banker', 'type': 'trick', 'candy': ['snickers','twix', 'mounds']}, {'costume':'slutty nurse', 'type': 'treat', 'candy': ['nerds','sour patch kids', 'm&m']}, {'costume':'slutty chef', 'type': 'trick', 'candy': ['apple','orange', 'razor blades']} ] dictionary_two = [ {'costume':'slutty mario', 'type': 'treat', 'candy': ['candy corn']}, {'costume':'slutty cat', 'type': 'treat', 'candy': ['snickers','m&m']}, {'costume':'slutty dog', 'type': 'trick', 'candy': ['vigra']}, {'costume':'slutty cat', 'type': 'treat', 'candy': ['twix', 'snickers','mounds']} ] temp_array = [] array_matches = [] for index, item in enumerate(dictionary_one): sorted_candy = ', '.join(sorted(item['candy'])) temp_array.append(sorted_candy) for index, item in enumerate(dictionary_two): sorted_candy = ', '.join(sorted(item['candy'])) if sorted_candy in temp_array: array_matches.append(sorted_candy) print 'match found:', sorted_candy
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question