In this message, the author has written
def neighbors((x, y)):
When I tried to run this with Python 3.3, it told me that it is invalid syntax. How do I solve the problem?
In this message, the author has written
def neighbors((x, y)):
When I tried to run this with Python 3.3, it told me that it is invalid syntax. How do I solve the problem?
The solution is to do:
def neighbors(point):
x, y = point
This feature was removed from 3.x, for a range of reasons.
Another option would be to write it as
def neighbors(x, y):
and replace:
for (nx, ny) in neighbors(path[-1]):
with
for (nx, ny) in neighbors(*path[-1]):