has_key() is method defined in python 2 so not available in Python 3.
so you can use directly check key in dictionary like this
Suppose graph is dictionary type
graph = {'A': ['B', 'C'], 'B': ['C', 'D'], 'C': ['D'], 'D': ['C'], 'E': ['F'], 'F': ['C']}
start = 'A'
if start in graph: print(start,' is found in graph') else: print(start,' is not found in graph')
Here is code example
def find_path(graph, start, end, path=[]): path = path + [start] if start == end: return path if start not in graph: return None for node in graph[start]: if node not in path: newpath = find_path(graph, node, end, path) if newpath: return newpath return None
find_path(graph, 'A', 'D')
Output: ['A', 'B', 'C', 'D']
Ask your question in comment box below our expert will answer
By the way, I am learning C++ language and I think this python is so much similar to C++. I am saying this because by reading this post it looks familiar with best assignment writing service uk well you guys knows better then me.
Your blog is too much amazing. I have found with ease what I was looking. Moreover, the content quality is awesome. Thanks for the nudge! free adult vr videos