My Global Variable In Python Cannot Be Referenced From Outside The Def It Was Created In
I am building a maze solver using the breadth first search algorithm and I keep hitting an error that says UnboundLocalError: local variable 'starting_point' referenced before assi
Solution 1:
global
tells a function to skip creating a local function slot for the variable and instead look in the global namespace. It doesn't actually create the variable. Since you don't call finished_maze
, visited
is never assigned.
Post a Comment for "My Global Variable In Python Cannot Be Referenced From Outside The Def It Was Created In"