Ask coding questions

← Back to all posts
stuck in this problem
SebaAle (0)

I have this homework where as the code says, i have to create a function that returns to its diagonal position if condition required, the problem is that the closest answer I've had ends up in looping

def rio(M,i,j):
l = 0
m=[[i,j]]
maxp = max_pend(M,i,j)
for i in range(1,len(M)-1):
for j in range(1,len(M)-1):
if [i-l,j-l] == maxp:
l += 1
m.append([i-l,j-l])
while i-l != 0 or j-l != 0:
return rio(M,i-l,j-l)
else:
break
return m