I am novice to python and I am trying to understand a basic error here . I am getting a TypeError: 'list' object is not callable error in the below code . Can somebody explain me what is wrong in my code ?
graph = {'a': ['b', 'c'], 'b': ['a', 'c'], 'c': ['b', 'd'], 'd': ['a'], 'e': ['a']}
def reachable(graph, node):
res = [node]
reachable = graph[node]
for currentnode in reachable:
if currentnode not in res :
reachableNodes = reachable(graph,currentnode) << TypeError:
for newNode in reachableNodes:
if newNode not in res :
res.append(newNode)
return res
Error : TypeError: 'list' object is not callable error
returnstatement is wrong.