Nested loop doubt

please explain the nested loop:print statement

Hi,
So your issue is with the print statement only.
print(max(x+1,y+1,n-x,n-y))

Let’s try to dry run this code:

there are 2 loops counter x and y. x runs for 5 times and y runs 5 times for every x means 5*5 =25 times

n=5

for x=0
for x=0, y=0
print(max(1,1,5,5)) => 5
for x=0 y=1
print(max(1,2,5,4)) => 5
for x=0 y=2
print(max(1,3,5,3)) => 5
for x=0 y=3
print(max(1,4,5,2)) => 5
for x=0 y=4
print(max(1,5,5,1)) => 5

output => 5 5 5 5 5

for x=1
for x=1, y=0
print(max(2,1,4,5)) => 5
for x=1 y=1
print(max(2,2,4,4)) => 4
for x=1 y=2
print(max(2,3,4,3)) => 4
for x=1 y=3
print(max(2,4,4,2)) => 4
for x=1 y=4
print(max(2,5,4,1)) => 5

output now: -
5 5 5 5 5
5 4 4 4 5

SImilarly for all the iteration.
I hope i am able to make this statement clear.