Python question



This Python question is not from code academy but I’m looking for some help on this question.

Would appreciate any help or advice:


(1) Create a function to transform a string structure like this:


into a Python dictionary like this:


Realize that ‘;’ separates items within the same dictionary index while ‘\n’ separates items on a different index.

(2) Create another function that transforms the python dictionary back to the string structure.

Appreciate any advice or help.

Thank you,


you could start by creating the list.

then use .split() to split the the items of different indexes (separated by \n).

then loop over the items of different indexes, within the loop create another list (index specific list). Then .split() the items within the same index, make the dictionaries and append them to the index specific list

after having dealt with each index specific list, append them to the result list (the list i mention in first paragraph of this reply)