I am trying to combine the keys of a dictionary when the values are the same as below,I am trying as below it only prints the values of the dictionary, any guidance how to fix this?
final_BATS_container_id_list = [
{'Rome_Nightly': ['15715489']},
{'Rome': ['15715490']},
{'Italy': ['15715491']},
{'Paris': ['15715491']},
{'France': ['15715491']},
{'Italy_Escape': ['15715493']},
{'Paris_Escape': ['15715493']},
{'France_Escape': ['15715493']}]
new_key = ''
for BATS_container_id_dict in final_BATS_container_id_list:
for key,value in BATS_container_id_dict.items():
print('key %s => value %s'%(key,value))
Expected output:-
[{'Rome_Nightly': ['15715489']},
{'Rome': ['15715490']},
{'Italy/Paris/France': ['15715491']},
{'Italy_Escape/Paris_Escape/France_Escape': ['15715493']}]