X = {"continent": "ASIA, EUROPE, AFRICA" , "Countries" : "JAPAN, GERMANY, EGYPT" , "Capital" : "TOKYO, BERLIN, CAIRO"}
The resulted dictionary should look like this
X = {"continent": ["ASIA", "EUROPE", "AFRICA"] , "Countries" : ["JAPAN", "GERMANY", "EGYPT"] , "Capital" : ["TOKYO", "BERLIN", "CAIRO"]}
Separated each value of X inside the list.
CodePudding user response:
You can use split
function which returns a list after separating a string by a given character.
for el in X:
X[el] = X[el].split(', ')