Is there a better way for me to write this without nesting it like this?
try:
if find_path(graph, startPos, (targetX+1,targetY,targetX,targetY)):
print('YES')
except:
try:
if find_path(graph, startPos, (targetX,targetY+1,targetX,targetY)):
print('YES')
except:
try:
if find_path(graph, startPos, (targetX-1,targetY,targetX,targetY)):
print('YES')
except:
try:
if find_path(graph, startPos, (targetX,targetY-1,targetX,targetY)):
print('YES')
except:
print('NO')