xeonthread

Untitled

Dec 16th, 2019
120
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. list1 = [{'a':[1,2,3]},{'b':[3,4,5]},{'c':[6,7,8]}]
  2. list2 = [{'a':[[1,2,3],[11,25,33]]},{'b':[[23,43,57],[22,4,5]]},{'c':[[9,10,65],[32,43,54]]}]
  3. result = []
  4. for i in list1:
  5.     for x in i.keys():
  6.         list_key = x
  7.     lst1_values = i.get(list_key)
  8.     for z in list2:
  9.         lst = z.get(list_key)
  10.         if lst:
  11.             list2_needed_key = lst
  12.     lst2_values = []
  13.     for b in list2_needed_key:
  14.         for a in b:
  15.             lst2_values.append(a)
  16.     result_list = []
  17.     for f in lst2_values:
  18.         if f in lst1_values:
  19.             result_list.append(f)
  20.     if result_list:
  21.         result_set = {list_key:result_list}
  22.         result.append(result_set)
  23. print(result)
RAW Paste Data