Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def map_keys_to_values_list(k_lst, v_lst):
- just_the_keys = {}
- i = 0
- ezerlist = []
- for value in k_lst:
- tuple = (k_lst[i], v_lst[i])
- i +=1
- if just_the_keys.has_key(value):
- if len(ezerlist) == 1:
- ezerlist.append(just_the_keys[value])
- ezerlist.append(tuple[1])
- ezerlist.append(just_the_keys[tuple[0]])
- just_the_keys[tuple[0]] = ezerlist
- ezerlist = []
- elif not just_the_keys.has_key(value):
- just_the_keys[value] = tuple[1]
- else:
- ezerlist.append(tuple[1])
- ezerlist == []
- return just_the_keys
- k_lst = ["a", "b", "c", "a", "a", "a", "c"]
- v_lst = [1, 2, 3, 1, 15, 6, 7]
- print map_keys_to_values_list(k_lst, v_lst)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement