i have list list
["Germany + A", "France + A", "England + B", "Germany + A" ]
- I need to convert Dictionary
- I need to split by +
- Convert into dictionary and swap the values
- if the values are present then no need to process
Expected is dictionary {"A":["Germany", "France"],"B":["England"] }
code is below, i got the output as dictionary only and need to insert one condition if the values are present then no need to process
l = ["Germany + A", "France + A", "England + B", "Germany + A" ]
m = []
for i in l:
m.append(i.split('+'))
for k,v in m:
n ={k:v}
print({v: k for k, v in n.items()}