Please tell error in my code

Please tell error in my code. Its failing for some test cases

hey @shreoshiroy ,
can you please share your code.

size = int(input())

flag = 0

prev = -32766

for i in range(0,size):

num = int(input())

if(flag == 0 and num<=prev):        #flag = 0 means increasing sequence is going on

    flag = 1

elif(flag == 1 and num>= prev):

    flag = 2

    print('false')

    break



prev = num

if(flag == 0 or flag ==1):

print('true')

hey @shreoshiroy ,
your code is always returning true, because your first condition to check <= prev never results true and hence flag is always 0.

Think something different.

flag isn’t always zero, its getting updated and false is also getting printed.
prev gets updated in each iteration. And whenever the current num is smaller than the prev, the num<= prev condition becomes true and it marks that from here descending order is beginning

for an example ,
check your code on this input
4
1
2
3
2

output should be False.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.