def Print for in range for in range print 4d end print def Hod if i2 a

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
def Print(a):
for i in range(m + 2):
for j in range(n + 2):
print("%4d" %a[i][j], end = '')
print()
def Hod(a, i, j, d):
a[i][j] = d
if i == i2 and j == j2:
Print(a)
return
else:
for k in range(4):
if a[i + dx[k]][j + dy[k]] == 0:
Hod(a, i + dx[k], j + dy[k], d + 1)
a[i][j] = 0
m = 7
n = 5
print('<Л А Б И Р И Н Т>')
dx = [-1, 0, 0, 1]
dy = [0, -1, 1, 0]
a = [[0]*(n + 2) for i in range(m + 2)]
f = open('labirint.txt', 'r')
for i in range(m + 2):
a[i] = list(map(int, f.readline().split()))
Print(a)
f.close()
print('введи координаты входа: ', end='')
i1, j1=map(int, input().split())
print('введи координаты вывода: ', end ='')
i2, j2=map(int, input().split())
Hod(a, i1, j1, 1)
if a[i2][j2] == 0:
print('проход невозможен!')