[Solved] how to create Dictionary within a dictionary in python


>>> import json
>>> title, data = ('Marks_Subjects ', "[['Time', 'maths', 'Science', 'english'], ['2013-08-31-16', 100, 50, 65]]")
>>> title, sub_title = title.split('_')  # Split 'Mark' and 'Subjects'
>>> data = json.loads(data.replace("'", '"'))  # Deserialize the data list
>>> data = dict(zip(*data))  # make a dict of the two lists
>>> date = data.pop('Time')  # Extract the date
>>> # Create a dict using a comprehension.
...
>>> {title: {subject: {date: {sub_title: mark}}
...  for subject, mark in data.iteritems()}}
{'Marks': {'maths': {'2013-08-31-16': {'Subjects ': 100}}, 'Science': {'2013-08-31-16': {'Subjects ': 50}}, 'english': {'2013-08-31-16': {'Subjects ': 65}}}}

I must say that this data structure doesn’t make sense.

3

solved how to create Dictionary within a dictionary in python