INNER CODE UNIT · Python
remove
Kushal997-das/Project-Guidance · Desktop Application/Basic/Python/Maze Solver/main.py:24
def remove(self):
if self.empty():
raise Exception("Frontier is empty")
else:
node = self.frontier[-1]
self.frontier = self.frontier[:-1]
return node
class Maze:
def __init__(self, filename):
with open(filename) as f:
contents = f.read()
if contents.count("A") != 1:
raise Exception("Maze must have exactly one starting point.")
if contents.count("B") != 1:
raise Exception("Maze must have exactly one finishing point.")