problem.getSuccessors(getStartState()) - it returns something like ( (4,5) , north, 1) – that means 3 things – tuple, direction,cost.
I’m using a dictionary ,closed = {}
Now I need to put the output of above function in the dictionary “closed” – how can I do that??
I need to use only dictionary because I need to return “action” i.e North, south….at the end of function. after doing some iterations, my dict is going to have multiple entries such as ((4,5),north,1) , ((3,4),south,1) and I need to extract the key from the dict i.e (4,5) .what shud I use?
It entirely depends on what you want to use as the key, and what as the value! If the key is something completely unrelated to the tuple
( (4,5) , north, 1)(I’m not sure what thenorthidentifier is supposed to be or how it got thee — you sure it’s not the string'north'instead?!), then @mipadi’s answer is correct. If the first item (the nested tuple) is the key, the other two the value, then, afteryou’ll do:
If the “tuple and direction”, together, are the key, and just the cost is the value, then you’ll do, instead:
So, what is it that you intend to use as the key into the dictionary
closed?!