-1

Input :

"name=xyz,city=bangalore,company=abc,education=BE"

Output :

{"name":"xyz", "city":"bangalore", "company":"abc", "education":"B.E"}

I am able to get ['name=xyz', 'city=bangalore', 'company=abc', 'education=BE'] but am stuck on splitting the word inside the list and appending to dictionaries.

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61

1 Answers1

0

You can try something along these lines:

inp = "name=xyz,city=bangalore,company=abc,education=BE"

out = dict(x.split("=") for x in inp.split(","))
# {'name': 'xyz', 'city': 'bangalore', 'company': 'abc', 'education': 'BE'}
user2390182
  • 72,016
  • 6
  • 67
  • 89