How do I create a nested dictionary in python So, I want the data be in this form..
{Category_id: {Product_id:... productInstance},{prod_id_1: this instance}
Check my NestedDict class here: https://stackoverflow.com/a/16296144/2334951
>>> branches = [b for b in data.paths()]
>>> ['plumbers' in k for k in branches]
[True, False, True, False, False, False]
>>> any(['plumbers' in k for k in branches])
True
>>> [k for k in branches if 'plumbers' in k]
[['new york', 'queens county', 'plumbers'], ['new jersey', 'mercer county', 'plumbers']]
>>> [data[k] for k in branches if 'plumbers' in k]
[9, 3]
I hope that with some intuition this example covers the question.