I'm trying to return a tuple from a function but it only returns the first element , When I looked online all the resources said Its done the way I did it , any thoughts ? my code :
def depthFirst(initialState):
exploredCount = 1
visitedCount = 0
frontier=[]
frontier.append(initialState)
explored=[]
while len(frontier) > 0:
state=frontier.pop()
explored.append(state)
visitedCount = visitedCount + 1
if state in goalStates:
return state
nextStates=getNextStates(state)
for i in range(len(nextStates)):
if not nextStates[i] in frontier and not nextStates[i] in explored:
frontier.append(nextStates[i])
exploredCount = exploredCount + 1
return [initialState , exploredCount , visitedCount]
Im callingthe function like this :
ans = depthFirst(state)
arr = ans[0]
explored = arr[1]
visited = arr[2]
state? What doesgetNextStatesdo?