def func(l):
a_cond = True # considering list is in ascending order
d_cond = True # # considering list is in descending order
# checking if for any number my ascending condition false
for i in range(1,len(l)):
if not l[i]>l[i-1]:
a_cond = False
# if condition not false then return list is ascending
if a_cond:
return 'Ascending Order'
# if condition false then check for descending codition
for i in range(1, len(l)):
if not l[i]<l[i-1]:
d_cond = False
# check if all number in descending order
if d_cond:
return 'Descending order'
# if above both condition fail, list is in mix order
return 'Mix Order'
print(func([1,2,3,4,5]))
print(func([5,4,3,2,1]))
print(func([1,2,3,1,2]))
выход
Ascending Order
Descending order
Mix Order