Problem with the code

n=5
for x in range (n):
for y in range (n):
print(max(x+1,y+1,n-x,n-y),end=" “)
print()
i did not understand whats happening in this piece of code . like whats happening here ,print(max(x+1,y+1,n-x,n-y),end=” ")

Hey @Utkarsh-Madaan-2559055747708288, this code gives the output in spiral form as you can see in the video. To understand the functioning of print(max(x+1, y+1, n-x, n-y) , I have written it down for every iteration and you can see the trend in which the values of x, y, n-x and n-y change.

Hope this helps.
Happy Learning :slight_smile: