Project IA in Python -- UnboundLocalError: local variable 'x' referenced before assignment
<p>`</p>

<pre><code>def iterativeDeepeningSearch(problem):
    def depthLimitedDFS(node, problem, depth):
        if depth==0:
            return
        if problem.isGoalState(node[-1]):
            return node
        for move, acao, c in problem.getSuccessors(node[-1]):
            if move not in node: 
                ode = depthLimitedDFS(node+[move],problem, depth-1)
        if x:
            return x

    for depth in itertools.count():
        node = depthLimitedDFS([problem.getStartState()], problem, depth)
        if node:
            return node`
</code></pre>

<p>I am trying to execute this code into the project(Pacman), but it returns an error: Un bound Local Error: local variable 'x' referenced before assignment....</p>

<p>What <strong>python</strong> is saying to you is that you are trying to use <code>x</code> before any assignment on it. That is: you didn't use <code>x</code> <strong>at all</strong> and you are trying to inspect a possible value on it (which doesn't make sense).</p>

<p>What is <code>x</code> supposed to do in your code? Think about that and you will probably figure out what to do to solve your issue.</p>

python python-2.7 search graph