I have a dictionary in python that looks like this:
{(-1, 1): (0, 1),
(0, 0): [([([(1, 0), (0, 1)], (0, 1))], (1, 0))],
(0, 1): [([([((-1, 1), (0, 2))], (1, 1))], (0, 0))],
(0, 2): (0, 1)}
I don't want it to have all those extra brackets and parentheses. This is the code I used to create this dictionary:
if condition1==True:
if condition2==True:
if (x,y) in adjList_dict: ##if the (x,y) tuple key is already in the dict
##add tuple neighbours[i] to existing list of tuples
adjList_dict[(x,y)]=[(adjList_dict[(x,y)],neighbours[i])]
else:
adjList_dict.update( {(x,y) : neighbours[i]} )
I am just trying to create a dictionary where the keys are tuples and the value of each key is a list of tuples.
For example I want this result: (0, 0): [(1, 0), (0, 1), (0, 1), (1, 0)]
Can I flatten the output or should I change something in the creation of the dictionary?