How to delete a dict_key in python -
i trying code algorithm dijkstra in python3 , think have confused python 2 , python 3. want remove unseen_node
. code shown below
d={} p={} node in graph.keys(): d[node] = -1 p[node] = "" d[start] = 0 unseen_nodes = graph.keys() #graph dict while len(unseen_nodes)>0: shortest = none node = '' temp_node in unseen_nodes: if shortest == none: shortest = d[temp_node] elif(d[temp_node]<shortest): shortest = d[temp_node] node=temp_node unseen_nodes.remove(node) #gives attributeerror: 'dict_keys' object has no attribute'remove'
Comments
Post a Comment