Help me in solving RATINGINPRAC problem

My issue

t = int(input())

while t > 0:
n = int(input())
d = list(map(int, input().split()))
# Your code goes here
t -= 1

for i in range(n) :
    if d[i+1]<=d[i]:
        print("Yes")
        i +=1 
    else :
        print("No")

how ?

My code

t = int(input())

while t > 0:
    n = int(input())
    d = list(map(int, input().split()))
    # Your code goes here
    t -= 1
    
    for i in range(n) :
        if d[i+1]<=d[i]:
            print("Yes")
            i +=1 
        else :
            print("No")
    
    
        
    

Learning course: Arrays using Python
Problem Link: Difficulty Rating Order Practice Problem in - CodeChef

Your code has logic that prints Yes not after every example in the input but after every time in the array, it is right and prints No after every time it fails.

print("Yes")
i+=1

The code should have been:

flag=0
for i in range(n-1): # as we are comparing current with next
    if d[i+1] <= d[i]:
        pass # Do nothing as we need confirm till end if there are any discrepancies
    else:
        print("No")
        flag=1
        break
if not flag:
     print("Yes") # Now we are sure that there aren't any discrepancies in the array.