Input: {'canada': 'america,usa', 'japan': 'tokio,Africa,Europe}
Output: {'canada': ['america','usa'], 'japan': ['tokio','Africa','Europe']}
Something like this:
Dictionary= dict(e.split(',') for e in input)
CodePudding user response:
You can have a dictionary comprehension to create the new dict.
Dictionary= {k:e.split(',') for k,e in input.items()}
CodePudding user response:
for key in input:
input[key] = list(input[key].split(','))