Advertisement
Guest User

Untitled

a guest
Nov 21st, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. def map_keys_to_values_list(k_lst, v_lst):
  2. just_the_keys = {}
  3. i = 0
  4. ezerlist = []
  5.  
  6.  
  7. for value in k_lst:
  8. tuple = (k_lst[i], v_lst[i])
  9. i +=1
  10. if just_the_keys.has_key(value):
  11. if len(ezerlist) == 1:
  12. ezerlist.append(just_the_keys[value])
  13. ezerlist.append(tuple[1])
  14. ezerlist.append(just_the_keys[tuple[0]])
  15. just_the_keys[tuple[0]] = ezerlist
  16. ezerlist = []
  17. elif not just_the_keys.has_key(value):
  18. just_the_keys[value] = tuple[1]
  19. else:
  20. ezerlist.append(tuple[1])
  21. ezerlist == []
  22.  
  23.  
  24. return just_the_keys
  25.  
  26.  
  27. k_lst = ["a", "b", "c", "a", "a", "a", "c"]
  28. v_lst = [1, 2, 3, 1, 15, 6, 7]
  29.  
  30.  
  31. print map_keys_to_values_list(k_lst, v_lst)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement