Creating 2D dictionary in Python
It would have the following syntax
dict_names = {'d1' : {'name':'bob', 'place':'lawn', 'animal':'man'}, 'd2' : {'name':'spot', 'place':'bed', 'animal':'dog'}}
You can then look things up like
>>> dict_names['d1']['name']'bob'
Something like this would work:
set1 = { 'name': 'Michael', 'place': 'London', ... }# same for set2d = dict()d['set1'] = set1d['set2'] = set2
Then you can do:
d['set1']['name']
etc. It is better to think about it as a nested structure (instead of a 2D matrix):
{ 'set1': { 'name': 'Michael', 'place': 'London', ... } 'set2': { 'name': 'Michael', 'place': 'London', ... }}
Take a look here for an easy way to visualize nested dictionaries.
Something like this should work.
dictionary = dict()dictionary[1] = dict()dictionary[1][1] = 3print(dictionary[1][1])
You can extend it to higher dimensions as well.